Foundation patterns for CC 2.1.71 pipeline skills. This skill is loaded via the
frontmatter field — it provides patterns that parent skills follow.
CC 2.1.71流水线Skill的基础模式。该Skill通过
前置字段加载——它提供父Skill遵循的模式。
Pattern 1: MCP Detection (ToolSearch Probe)
模式1:MCP检测(ToolSearch探测)
Run BEFORE any MCP tool call. Probes are parallel and instant.
在任何MCP工具调用之前运行。探测是并行且即时的。
FIRST thing in any pipeline skill — all in ONE message:
FIRST thing in any pipeline skill — all in ONE message:
ToolSearch(query="select:mcp__memory__search_nodes")
ToolSearch(query="select:mcp__context7__resolve-library-id")
ToolSearch(query="select:mcp__sequential-thinking__sequentialthinking")
ToolSearch(query="select:mcp__memory__search_nodes")
ToolSearch(query="select:mcp__context7__resolve-library-id")
ToolSearch(query="select:mcp__sequential-thinking__sequentialthinking")
Store results for all phases:
Store results for all phases:
Write(".claude/chain/capabilities.json", JSON.stringify({
"memory": true_or_false,
"context7": true_or_false,
"sequential": true_or_false,
"timestamp": "ISO-8601"
}))
**Usage in phases:**
```python
Write(".claude/chain/capabilities.json", JSON.stringify({
"memory": true_or_false,
"context7": true_or_false,
"sequential": true_or_false,
"timestamp": "ISO-8601"
}))
BEFORE any mcp__memory__ call:
BEFORE any mcp__memory__ call:
if capabilities.memory:
mcp__memory__search_nodes(query="...")
if capabilities.memory:
mcp__memory__search_nodes(query="...")
else: skip gracefully, no error
else: skip gracefully, no error
Load details: `Read("${CLAUDE_SKILL_DIR}/references/mcp-detection.md")`
加载详情:`Read("${CLAUDE_SKILL_DIR}/references/mcp-detection.md")`
Pattern 2: Handoff Files
模式2:交接文件
Write structured JSON after every major phase. Survives context compaction and rate limits.
python
Write(".claude/chain/NN-phase-name.json", JSON.stringify({
"phase": "rca",
"skill": "fix-issue",
"timestamp": "ISO-8601",
"status": "completed",
"outputs": { ... }, # phase-specific results
"mcps_used": ["memory"],
"next_phase": 5
}))
Location: — numbered files for ordering, descriptive names for clarity.
Load schema:
Read("${CLAUDE_SKILL_DIR}/references/handoff-schema.md")
在每个主要阶段后写入结构化JSON。可在上下文压缩和速率限制下保留数据。
python
Write(".claude/chain/NN-phase-name.json", JSON.stringify({
"phase": "rca",
"skill": "fix-issue",
"timestamp": "ISO-8601",
"status": "completed",
"outputs": { ... }, # phase-specific results
"mcps_used": ["memory"],
"next_phase": 5
}))
存储位置: — 编号文件用于排序,描述性名称提升可读性。
加载Schema:
Read("${CLAUDE_SKILL_DIR}/references/handoff-schema.md")
Pattern 3: Checkpoint-Resume
模式3:断点续传
Read state at skill start. If found, skip completed phases.
在Skill启动时读取状态。如果找到状态,则跳过已完成的阶段。
FIRST instruction after MCP probe:
FIRST instruction after MCP probe:
Read(".claude/chain/state.json")
Read(".claude/chain/state.json")
If exists and matches current skill:
If exists and matches current skill:
→ Read last handoff file
→ Read last handoff file
→ Skip to current_phase
→ Skip to current_phase
→ Tell user: "Resuming from Phase N"
→ Tell user: "Resuming from Phase N"
If not exists:
If not exists:
Write(".claude/chain/state.json", JSON.stringify({
"skill": "fix-issue",
"started": "ISO-8601",
"current_phase": 1,
"completed_phases": [],
"capabilities": { ... }
}))
Write(".claude/chain/state.json", JSON.stringify({
"skill": "fix-issue",
"started": "ISO-8601",
"current_phase": 1,
"completed_phases": [],
"capabilities": { ... }
}))
After each major phase:
After each major phase:
Update state.json with new current_phase and append to completed_phases
Update state.json with new current_phase and append to completed_phases
Load protocol: `Read("${CLAUDE_SKILL_DIR}/references/checkpoint-resume.md")`
加载协议:`Read("${CLAUDE_SKILL_DIR}/references/checkpoint-resume.md")`
Pattern 4: Worktree-Isolated Agents
模式4:工作树隔离Agent
Use
when spawning agents that WRITE files in parallel.
Agents editing different files in parallel:
Agents editing different files in parallel:
Agent(
subagent_type="backend-system-architect",
prompt="Implement backend for: {feature}...",
isolation="worktree", # own copy of repo
run_in_background=true
)
**When to use worktree:** Agents with Write/Edit tools running in parallel.
**When NOT to use:** Read-only agents (brainstorm, assessment, review).
Load details: `Read("${CLAUDE_SKILL_DIR}/references/worktree-agent-pattern.md")`
Agent(
subagent_type="backend-system-architect",
prompt="Implement backend for: {feature}...",
isolation="worktree", # own copy of repo
run_in_background=true
)
**何时使用工作树:** 带有Write/Edit工具且并行运行的Agent。
**何时不使用:** 只读Agent(头脑风暴、评估、评审)。
加载详情:`Read("${CLAUDE_SKILL_DIR}/references/worktree-agent-pattern.md")`
Pattern 5: CronCreate Monitoring
模式5:CronCreate监控
Schedule post-completion health checks that survive session end.
Guard: Skip cron in headless/CI (CLAUDE_CODE_DISABLE_CRON)
Guard: Skip cron in headless/CI (CLAUDE_CODE_DISABLE_CRON)
if env CLAUDE_CODE_DISABLE_CRON is set, run a single check instead
if env CLAUDE_CODE_DISABLE_CRON is set, run a single check instead
CronCreate(
schedule="*/5 * * * *",
prompt="Check CI status for PR #{number}:
Run: gh pr checks {number} --repo {repo}
All pass → CronDelete this job, report success.
Any fail → alert with failure details."
)
Load patterns: `Read("${CLAUDE_SKILL_DIR}/references/cron-monitoring.md")`
CronCreate(
schedule="*/5 * * * *",
prompt="Check CI status for PR #{number}:
Run: gh pr checks {number} --repo {repo}
All pass → CronDelete this job, report success.
Any fail → alert with failure details."
)
加载模式:`Read("${CLAUDE_SKILL_DIR}/references/cron-monitoring.md")`
Pattern 6: Progressive Output (CC 2.1.76)
模式6:渐进式输出(CC 2.1.76)
Launch agents with
and output results as each returns — don't wait for all agents to finish. Gives ~60% faster perceived feedback.
使用
启动Agent,在每个Agent返回结果时立即输出——无需等待所有Agent完成。可将感知反馈速度提升约60%。
Launch all agents in ONE message with run_in_background=true
Launch all agents in ONE message with run_in_background=true
Agent(subagent_type="backend-system-architect",
prompt="...", run_in_background=true, name="backend")
Agent(subagent_type="frontend-ui-developer",
prompt="...", run_in_background=true, name="frontend")
Agent(subagent_type="test-generator",
prompt="...", run_in_background=true, name="tests")
Agent(subagent_type="backend-system-architect",
prompt="...", run_in_background=true, name="backend")
Agent(subagent_type="frontend-ui-developer",
prompt="...", run_in_background=true, name="frontend")
Agent(subagent_type="test-generator",
prompt="...", run_in_background=true, name="tests")
As each agent completes, output its findings immediately.
As each agent completes, output its findings immediately.
CC delivers background agent results as notifications —
CC delivers background agent results as notifications —
present each result to the user as it arrives.
present each result to the user as it arrives.
If any agent scores below threshold, flag it before others finish.
If any agent scores below threshold, flag it before others finish.
**Key rules:**
- Launch ALL independent agents in a single message (parallel)
- Output each result incrementally — don't batch
- Flag critical findings immediately (don't wait for stragglers)
- Background bash tasks are killed at 5GB output (CC 2.1.77) — pipe verbose output to files
**核心规则:**
- 在单条消息中启动所有独立Agent(并行执行)
- 逐步输出每个结果——不要批量等待
- 立即标记关键问题(不要等待滞后的Agent)
- 后台bash任务在输出达到5GB时会被终止(CC 2.1.77)——将详细输出管道到文件
Pattern 7: SendMessage Agent Resume (CC 2.1.77)
模式7:SendMessage Agent续传(CC 2.1.77)
Continue a previously spawned agent using
. CC 2.1.77 auto-resumes stopped agents — no error handling needed.
使用
继续之前生成的Agent。CC 2.1.77会自动恢复已停止的Agent——无需错误处理。
Agent(subagent_type="backend-system-architect",
prompt="Design the API schema", name="api-designer")
Agent(subagent_type="backend-system-architect",
prompt="Design the API schema", name="api-designer")
Later, continue the same agent with new context
Later, continue the same agent with new context
SendMessage(to="api-designer", content="Now implement the schema you designed")
SendMessage(to="api-designer", content="Now implement the schema you designed")
CC 2.1.77: SendMessage auto-resumes stopped agents.
CC 2.1.77: SendMessage auto-resumes stopped agents.
No need to check agent state or handle "agent stopped" errors.
No need to check agent state or handle "agent stopped" errors.
NEVER use Agent(resume=...) — removed in 2.1.77.
NEVER use Agent(resume=...) — removed in 2.1.77.
Pattern 8: /loop Skill Chaining (CC 2.1.71)
模式8:/loop Skill链式调用(CC 2.1.71)
runs a prompt or skill on a recurring interval — session-scoped, dies on exit, 3-day auto-expiry. Unlike
(agent-initiated),
is user-invoked and can chain other skills.
可按重复间隔运行提示或Skill——会话作用域,退出时终止,3天后自动过期。与
(由Agent发起)不同,
由用户调用且可链式调用其他Skill。
User types these — skills suggest them in "Next Steps"
User types these — skills suggest them in "Next Steps"
/loop 5m gh pr checks 42 # Watch CI after push
/loop 20m /ork:verify authentication # Periodic quality gate
/loop 10m npm test -- --coverage # Coverage drift watch
/loop 1h check deployment health at /api/health # Post-deploy monitor
**Key difference from CronCreate:**
- `/loop` can invoke skills: `/loop 20m /ork:verify` (CronCreate can't)
- Both use the same underlying scheduler (50-task limit, 3-day expiry)
- Skills use `CronCreate` for agent-initiated scheduling
- Skills suggest `/loop` in "Next Steps" for user-initiated monitoring
**When to suggest /loop in Next Steps:**
- After creating a PR → `/loop 5m gh pr checks {pr_number}`
- After running tests → `/loop 10m npm test`
- After deployment → `/loop 1h check health at {endpoint}`
- After verification → `/loop 30m /ork:verify {scope}`
/loop 5m gh pr checks 42 # Watch CI after push
/loop 20m /ork:verify authentication # Periodic quality gate
/loop 10m npm test -- --coverage # Coverage drift watch
/loop 1h check deployment health at /api/health # Post-deploy monitor
**与CronCreate的核心区别:**
- `/loop`可调用Skill:`/loop 20m /ork:verify`(CronCreate不支持)
- 两者使用相同的底层调度器(50任务限制,3天过期)
- Skill使用`CronCreate`进行Agent发起的调度
- Skill在「下一步」中建议用户使用`/loop`进行用户发起的监控
**何时在「下一步」中建议使用/loop:**
- 创建PR后 → `/loop 5m gh pr checks {pr_number}`
- 运行测试后 → `/loop 10m npm test`
- 部署后 → `/loop 1h check health at {endpoint}`
- 验证后 → `/loop 30m /ork:verify {scope}`
| Rule | Impact | Key Pattern |
|---|
rules/probe-before-use.md
| HIGH | Always ToolSearch before MCP calls |
rules/handoff-after-phase.md
| HIGH | Write handoff JSON after every major phase |
rules/checkpoint-on-gate.md
| MEDIUM | Update state.json at every user gate |
| 规则 | 影响级别 | 核心模式 |
|---|
rules/probe-before-use.md
| 高 | 调用MCP前必须执行ToolSearch |
rules/handoff-after-phase.md
| 高 | 每个主要阶段后写入交接JSON |
rules/checkpoint-on-gate.md
| 中 | 在每个用户交互节点更新state.json |
Load on demand with
Read("${CLAUDE_SKILL_DIR}/references/<file>")
:
| File | Content |
|---|
| ToolSearch probe pattern + capability map |
| JSON schema for |
| state.json schema + resume protocol |
worktree-agent-pattern.md
| usage guide |
| CronCreate patterns for post-task health |
| Progressive output with run_in_background |
| SendMessage auto-resume (CC 2.1.77) |
| T1/T2/T3 graceful degradation |
通过
Read("${CLAUDE_SKILL_DIR}/references/<file>")
按需加载:
| 文件 | 内容 |
|---|
| ToolSearch探测模式 + 能力映射 |
| 的JSON Schema |
| state.json Schema + 续传协议 |
worktree-agent-pattern.md
| 使用指南 |
| 任务后健康检查的CronCreate模式 |
| 结合run_in_background的渐进式输出 |
| SendMessage自动续传(CC 2.1.77) |
| T1/T2/T3优雅降级 |
- — Full-power feature implementation (primary consumer)
- — Issue debugging and resolution pipeline
- — Post-implementation verification
- — Design exploration pipeline
- — 全功能特性实现(主要使用者)
- — 问题调试与解决流水线
- — 实现后验证
- — 设计探索流水线