Skip to main content

Claude Code Generator Plugin

The Claude Code Generator plugin is a full pipeline plugin that delegates the entire work generation process to Claude Code. It runs a single Claude Code CLI session that autonomously handles web search, content creation, and file generation within a sandboxed workspace.

Source: packages/plugins/claude-code/src/claude-code.plugin.ts

Overview

PropertyValue
Plugin IDclaude-code
Categorypipeline
Capabilitiespipeline, form-schema-provider
Version1.0.0
Configuration Modeuser-required
Auto-enableNo
Built-inYes
System PluginNo

The plugin implements IPlugin, IPipelinePlugin, and IFormSchemaProvider.

Architecture

How It Works

Unlike other pipeline plugins that orchestrate multiple internal steps with facades, the Claude Code Generator hands the entire generation task to the Claude Code CLI as a subprocess. The CLI runs with a tailored system prompt, has access to web search through its built-in tools, and writes generated items as JSON files to a temporary workspace.

Pipeline Steps

The plugin runs 6 sequential steps:

StepIDDescriptionDuration
1setup-claude-codeDownloads and caches the Claude Code CLI binary for the configured version~5s
2prepare-contextCreates a temp workspace, seeds it with existing items and work metadata~2s
3generate-itemsRuns the Claude Code CLI to research and generate items as JSON files~60-180s
4collect-resultsReads generated JSON files from the workspace work~2s
5capture-screenshotsTakes screenshots for items that need images (optional)~30s
6cleanupRemoves the temporary workspace work~1s

Configuration

Settings Schema

SettingTypeDefaultDescription
oauthTokenstring--Claude Code OAuth token (from claude setup-token)
apiKeystring--Anthropic API key (from console.anthropic.com)
versionstringLatestClaude Code CLI version to use (hidden)
maxTurnsintegerDefaultMaximum number of agentic turns (1--100, hidden)
maxBudgetUsdnumber--Maximum budget in USD per generation (hidden)
modelstring--Model alias (sonnet, opus) or full name

Authentication

At least one of oauthToken or apiKey must be configured. The settings schema enforces this through the x-requiredGroups extension. OAuth token takes precedence when both are present.

OAuth Token (recommended):

claude setup-token

API Key:

Get one from console.anthropic.com.

Environment Variables

VariableDescription
PLUGIN_CLAUDE_CODE_OAUTH_TOKENOAuth token fallback

Features

Binary Management

The ensureBinary() utility in utils/binary-manager.ts handles downloading and caching the Claude Code CLI binary. It checks whether the requested version is already cached, downloads it if needed, and returns the path to the executable.

Workspace Sandbox

Each generation runs in an isolated temporary workspace:

  1. Creation -- a unique work is created under a base temp work
  2. Seeding -- existing items are written as reference files, and metadata (work name, description, categories, tags, brands) is written as context files
  3. Onboarding config -- ensures the Claude Code CLI has necessary configuration
  4. Cleanup -- the workspace is removed after generation, even if an error occurs

Taxonomy Watcher

The startTaxonomyWatcher() utility monitors the workspace for new item files during generation. As Claude Code writes items to disk, the watcher detects them and reports progress to the UI in real time (e.g., "Generated 5 of 20 items").

Process Management

The executeClaudeCode() function spawns the CLI as a child process with:

  • A system prompt providing generation instructions
  • A user prompt with the specific work request
  • Environment variables for authentication
  • Configurable max turns and budget limits
  • Abort signal support for cancellation

The returned kill function allows the pipeline to terminate the process if the user cancels generation.

Screenshot Capture

After items are collected, the plugin optionally captures screenshots using the configured screenshot provider. This step is skipped if:

  • capture_screenshots is set to false in the request config
  • No items were generated
  • No screenshot facade is available
  • The generation was cancelled

Selectable Provider Categories

The Claude Code Generator only allows selecting a screenshot provider. All other functionality (search, content extraction) is handled internally by Claude Code.

Getting Started

  1. Enable the Claude Code Generator plugin on the Plugins page
  2. Configure authentication with either an OAuth token or API key
  3. Optionally set a model and budget limit
  4. Select "Claude Code Generator" as the pipeline provider when generating a work
  5. Generation will run autonomously -- Claude Code handles research and item creation

API Reference

Class: ClaudeCodePlugin

class ClaudeCodePlugin implements IPlugin, IPipelinePlugin, IFormSchemaProvider {
readonly id: 'claude-code';
readonly category: 'pipeline';

execute(work, request, existing, options?, onProgress?): Promise<PipelineResult>;
cancel(): Promise<void>;
getState(): PipelineState<ClaudeCodeStepId> | null;
getStepDefinitions(): readonly PipelineStepDefinition[];
getFormFields(): FormFieldDefinition[];
getFormGroups(): FormFieldGroup[];
validateFormInput(values): ValidationResult;
getDefaultValues(): Record<string, unknown>;
}

Key Types

TypePurpose
ClaudeCodeStepIdUnion of the 6 step IDs
ExecuteResultResult from the CLI process (exitCode, stdout, stderr, killed)

Comparison with Other Pipelines

AspectClaude Code GeneratorAgent PipelineStandard Pipeline
Execution modelExternal CLI subprocessIn-process AI agentEngine-orchestrated steps
SearchBuilt-in Claude Code toolsConfigurable search facadeConfigurable search facade
AI providerAnthropic onlyAny OpenAI-compatibleAny provider
AuthenticationOAuth token or Anthropic API keyVia AI provider pluginVia AI provider plugin
Budget controlBuilt-in USD budget limitToken limit via maxStepsNo built-in limit
Steps6515