/chain-patterns
Chain patterns for multi-phase pipelines: MCP detection, handoff files, checkpoint-resume, worktree agents, CronCreate monitoring. Use when building or debugging a pipeline skill.
$ npx -y skills add yonatangross/orchestkit --skill chain-patterns --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/chain-patterns
Context preview
The summary Claude sees to decide when to auto-load this skill.
Chain patterns for multi-phase pipelines: MCP detection, handoff files, checkpoint-resume, worktree agents, CronCreate monitoring. Use when building or debugging a pipeline skill.
SKILL.md
chain-patterns.SKILL.mdname: chain-patterns
compatibility: "Claude Code 2.1.220+"
description: "Chain patterns for multi-phase pipelines: MCP detection, handoff files, checkpoint-resume, worktree agents, CronCreate monitoring. Use when building or debugging a pipeline skill."
tags: [pipeline, resilience, checkpoint, mcp, orchestkit]
version: 1.0.0
author: OrchestKit
user-invocable: false
context: inherit
allowed-tools: [Read, ToolSearch]
complexity: medium
persuasion-type: guidance
model: haiku
# Reference skill: fenced calls below teach a pattern, they are not calls this
# skill makes. Widening allowed-tools to satisfy the coverage gate would grant real
# permissions (Agent, CronCreate) to something that never acts.
tool-coverage: illustrative
Chain Patterns
Overview
Foundation patterns for CC 2.1.71 pipeline skills. This skill is loaded via the `skills:` frontmatter field — it provides patterns that parent skills follow.
Pattern 1: MCP Detection (ToolSearch Probe)
Run BEFORE any MCP tool call. Probes are parallel and instant.
# 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")
# 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:**
# BEFORE any mcp__memory__ call:
if capabilities.memory:
mcp__memory__search_nodes(query="...")
# else: skip gracefully, no errorLoad details: `Read("${CLAUDE_SKILL_DIR}/references/mcp-detection.md")`
Pattern 2: Handoff Files
Write structured JSON after every major phase. Survives context compaction and rate limits.
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:** `.claude/chain/` — numbered files for ordering, descriptive names for clarity.
Load schema: `Read("${CLAUDE_SKILL_DIR}/references/handoff-schema.md")`
Pattern 3: Checkpoint-Resume
Read state at skill start. If found, skip completed phases.
# FIRST instruction after MCP probe:
Read(".claude/chain/state.json")
# If exists and matches current skill:
# → Read last handoff file
# → Skip to current_phase
# → Tell user: "Resuming from Phase N"
# If not exists:
Write(".claude/chain/state.json", JSON.stringify({
"skill": "fix-issue",
"started": "ISO-8601",
"current_phase": 1,
"completed_phases": [],
"capabilities": { ... }
}))
# After each major phase:
# Update state.json with new current_phase and append to completed_phasesLoad protocol: `Read("${CLAUDE_SKILL_DIR}/references/checkpoint-resume.md")`
Pattern 4: Worktree-Isolated Agents
Use `isolation: "worktree"` when spawning agents that WRITE files in parallel.
# Agents editing different files in parallel:
Agent(
subagent_type="ork: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.
> **CC 2.1.157 worktree lifecycle:** `EnterWorktree` can switch between Claude-managed worktrees mid-session, and worktrees are left **unlocked** when the agent finishes — so `git worktree remove`/`prune` cleans them up without `--force`.
> **Session-aware worktree check (CC 2.1.145):** before parallel-worktree work, detect concurrent same-repo sessions with `claude agents --json` (filter by `working_dir`) rather than `ps`/`pgrep` — it returns `session_id`, `parent_agent_id`, `working_dir`, `awaiting_input`, and `elapsed` per live session, so you can tell *which* sessions share this repo. **When NOT to use:** Read-only agents (brainstorm, assessment, review).
Load details: `Read("${CLAUDE_SKILL_DIR}/references/worktree-agent-pattern.md")`
Pattern 5: CronCreate Monitoring
Schedule post-completion health checks that survive session end.
# Guard: Skip cron in headless/CI (CLAUDE_CODE_DISABLE_CRON)
# 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")`
Pattern 6: Progressive Output (CC 2.1.76)
Launch agents with `run_in_background=true` and output results as each returns — don't wait for all agents to finish. Gives ~60% faster perceived feedback.
> **Background by default (CC 2.1.198+):** Agent-tool subagents launch in the background even when `run_in_background` is omitted. Pass `run_in_background: false` only when a stage must block on the result before continuing (e.g. a verdict gate ahead of a destructive step). The `Notification` hook fires `agent_needs_input` / `agent_completed` as background agents progress — ork's notification hooks surface both. > > **Skill-side twin (CC 2.1.218+):** skills with `context: fork` also background by default; the per-skill opt-out is `background: false` in frontmatter. ork's rule: every `user-invocable: true` fork skill declares it (a human typed the command and is waiting — verdict gates and AskUserQuestion turns need the interactive loop), while model-invoked fork skills deliberately keep the background default, which is the 2.1.218 win. When authoring a pipeline skill, decide this explicitly rather than inheriting whatever the current default is (#3093).
# Launch all agents in ONE message with run_in_background=true
Agent(sub
Read more
name: chain-patterns compatibility: "Claude Code 2.1.220+" description: "Chain patterns for multi-phase pipelines: MCP detection, handoff files, checkpoint-resume, worktree agents, CronCreate monitoring. Use when building or debugging a pipeline skill." tags: [pipeline, resilience, checkpoint, mcp, orchestkit] version: 1.0.0 author: OrchestKit user-invocable: false context: inherit allowed-tools: [Read, ToolSearch] complexity: medium persuasion-type: guidance model: haiku # Reference skill: fenced calls below teach a pattern, they are not calls this # skill makes. Widening allowed-tools to satisfy the coverage gate would grant real # permissions (Agent, CronCreate) to something that never acts. tool-coverage: illustrative
Chain Patterns
Overview
Foundation patterns for CC 2.1.71 pipeline skills. This skill is loaded via the `skills:` frontmatter field — it provides patterns that parent skills follow.
Pattern 1: MCP Detection (ToolSearch Probe)
Run BEFORE any MCP tool call. Probes are parallel and instant.
# 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")
# 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:**
# BEFORE any mcp__memory__ call:
if capabilities.memory:
mcp__memory__search_nodes(query="...")
# else: skip gracefully, no errorLoad details: `Read("${CLAUDE_SKILL_DIR}/references/mcp-detection.md")`
Pattern 2: Handoff Files
Write structured JSON after every major phase. Survives context compaction and rate limits.
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:** `.claude/chain/` — numbered files for ordering, descriptive names for clarity.
Load schema: `Read("${CLAUDE_SKILL_DIR}/references/handoff-schema.md")`
Pattern 3: Checkpoint-Resume
Read state at skill start. If found, skip completed phases.
# FIRST instruction after MCP probe:
Read(".claude/chain/state.json")
# If exists and matches current skill:
# → Read last handoff file
# → Skip to current_phase
# → Tell user: "Resuming from Phase N"
# If not exists:
Write(".claude/chain/state.json", JSON.stringify({
"skill": "fix-issue",
"started": "ISO-8601",
"current_phase": 1,
"completed_phases": [],
"capabilities": { ... }
}))
# After each major phase:
# Update state.json with new current_phase and append to completed_phasesLoad protocol: `Read("${CLAUDE_SKILL_DIR}/references/checkpoint-resume.md")`
Pattern 4: Worktree-Isolated Agents
Use `isolation: "worktree"` when spawning agents that WRITE files in parallel.
# Agents editing different files in parallel:
Agent(
subagent_type="ork: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.
> **CC 2.1.157 worktree lifecycle:** `EnterWorktree` can switch between Claude-managed worktrees mid-session, and worktrees are left **unlocked** when the agent finishes — so `git worktree remove`/`prune` cleans them up without `--force`.
> **Session-aware worktree check (CC 2.1.145):** before parallel-worktree work, detect concurrent same-repo sessions with `claude agents --json` (filter by `working_dir`) rather than `ps`/`pgrep` — it returns `session_id`, `parent_agent_id`, `working_dir`, `awaiting_input`, and `elapsed` per live session, so you can tell *which* sessions share this repo. **When NOT to use:** Read-only agents (brainstorm, assessment, review).
Load details: `Read("${CLAUDE_SKILL_DIR}/references/worktree-agent-pattern.md")`
Pattern 5: CronCreate Monitoring
Schedule post-completion health checks that survive session end.
# Guard: Skip cron in headless/CI (CLAUDE_CODE_DISABLE_CRON)
# 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")`
Pattern 6: Progressive Output (CC 2.1.76)
Launch agents with `run_in_background=true` and output results as each returns — don't wait for all agents to finish. Gives ~60% faster perceived feedback.
> **Background by default (CC 2.1.198+):** Agent-tool subagents launch in the background even when `run_in_background` is omitted. Pass `run_in_background: false` only when a stage must block on the result before continuing (e.g. a verdict gate ahead of a destructive step). The `Notification` hook fires `agent_needs_input` / `agent_completed` as background agents progress — ork's notification hooks surface both. > > **Skill-side twin (CC 2.1.218+):** skills with `context: fork` also background by default; the per-skill opt-out is `background: false` in frontmatter. ork's rule: every `user-invocable: true` fork skill declares it (a human typed the command and is waiting — verdict gates and AskUserQuestion turns need the interactive loop), while model-invoked fork skills deliberately keep the background default, which is the 2.1.218 win. When authoring a pipeline skill, decide this explicitly rather than inheriting whatever the current default is (#3093).
# Launch all agents in ONE message with run_in_background=true Agent(sub
Showing the first part of this file.
The Complete AI Development Toolkit for Claude Code — 114 skills, 37 agents, 212 hooks. Production-ready patterns for full-stack development.
Repo: yonatangross/orchestkit
Other skills on orchestkit.
- /accessibility
Accessibility patterns for WCAG 2.2 compliance, keyboard focus management, React Aria component patterns, cognitive inclusion, native HTML-first philosophy, and user preference honoring. Use when implementing screen reader support, keyboard navigation, ARIA patterns, focus
Open skill - /agent-orchestration
Agent orchestration patterns for agentic loops, multi-agent coordination, alternative frameworks, and multi-scenario workflows. Use when building autonomous agent loops, coordinating multiple agents, evaluating CrewAI/AutoGen/Swarm, or orchestrating complex multi-step scenarios.
Open skill - /ai-ui-generation
AI-assisted UI generation patterns for json-render, v0.app, Google Stitch, Bolt Cloud, and Cursor workflows. Covers prompt engineering for component and full-stack app generation, review checklists for AI-generated code, design token injection, refactoring for design system
Open skill - /analytics
Queries local analytics across OrchestKit projects for agent usage, skill frequency, hook timing, team activity, session replay, cost estimation, and model delegation trends. Privacy-safe with hashed project IDs. Supports time-range filtering and comparative analysis. Use when
Open skill - /animation-motion-design
Animation and motion design patterns using Motion library (formerly Framer Motion) and View Transitions API. Use when implementing component animations, page transitions, micro-interactions, gesture-driven UIs, or ensuring motion accessibility with prefers-reduced-motion.
Open skill - /api-design
API contract design for REST and GraphQL, covering resource shape, URL and header versioning with deprecation windows, RFC 9457 Problem Details error handling, and OpenAPI specs. Use when specifying the wire contract an endpoint exposes, choosing a versioning scheme, or
Open skill

