Pipeline Architecture
How the pipeline spawner works — from trigger to output.
Pipeline Architecture
This page explains the internals of the pipeline system: how definitions are discovered, how the spawner works, and how to extend it.
Pipeline Definition Format
Every pipeline is a Markdown file at knowledge/system/rules/pipelines/<name>.md. The filename (minus .md) becomes the trigger name.
Frontmatter
---
type: pipeline
domain: lead-generation # lead-generation, client-delivery, operations
status: active # active, draft, deprecated
model: sonnet # Default model: haiku, sonnet, opus
passes: # Optional — omit for single-pass
- name: research
model: sonnet
- name: synthesis
model: opus
permissions: rw-knowledge # read-only, rw-knowledge, full
review_gate: false # If true, stops between passes for approval
summary: One-line description
---Required Body Sections
- Preflight Check — validates inputs before execution
- Purpose — what the pipeline accomplishes
- Flow — step-by-step instructions for each pass
- Output Format — template for the output file
- Rules — constraints and guardrails
- Error Handling — what to do when tools are unavailable
Discovery Chain
pipeline-prompt.tsdefinesPIPELINES_DIRas$KNOWLEDGE_DIR/system/rules/pipelines/- When a trigger arrives,
getSystemPrompt(pipelineName)reads the definition getFrontmatterModel(pipelineName)extracts the model for routinggetPipelinePasses(pipelineName)parses multi-pass configurationgetPipelinePermissionsTier(pipelineName)enforces access levels
Spawner Behavior
The spawner in spawner.ts manages pipeline execution:
- Max turns — each pipeline has a configurable maximum number of tool-use turns (default: 25)
- Parallel limit — maximum 3 concurrent jobs (configurable via
MAX_PARALLEL_PIPELINES) - Shell safety — all commands use
execFileSyncwith argument arrays (never string interpolation) - Pipeline name validation — must match
/^[a-z0-9_-]+$/
Permission Tiers
| Tier | Access |
|---|---|
read-only | Can read files but not modify the knowledge vault |
rw-knowledge | Can read and write to the knowledge vault |
full | Full file system access (for build pipelines) |
Adding a New Pipeline
- Create the
.mdfile inknowledge/system/rules/pipelines/ - Add a max-turns entry in
spawner.tsPIPELINE_MAX_TURNSmap - Add the trigger to
knowledge/system/CLAUDE.mdPipeline Triggers table - Restart the pipeline server
- Trigger from Mission Control or via API
The Document Compiler
The compile feature is a document compiler with 7 types — it is architecturally different from the 17 pipelines. It sends a chat command rather than spawning a full Claude Code process. Use it to transform raw pipeline output into branded client-ready documents:
compile [doc-type] [client-name]The compiler reads formatting rules from system/rules/compile-guidelines.md and applies brand tokens from the client's brand.md and voice.md files.