chain-patterns
Chain patterns for CC 2.1.71 pipelines — MCP detection, handoff files, checkpoint-resume, worktree agents, CronCreate monitoring. Use when building multi-phase pipeline skills. Loaded via skills: field by pipeline skills (fix-issue, implement, brainstorm, verify). Not user-invocable.
What this skill does
# 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.
```python
# 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:**
```python
# BEFORE any mcp__memory__ call:
if capabilities.memory:
mcp__memory__search_nodes(query="...")
# else: skip gracefully, no error
```
Load 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.
```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:** `.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.
```python
# 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_phases
```
Load 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.
```python
# 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.
> **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.
```python
# 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.
```python
# 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")
# As each agent completes, output its findings immediately.
# CC delivers background agent results as notifications —
# present each result to the user as it arrives.
# 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
- Parallel tool calls fail independently (CC 2.1.161) — a failed Bash no longer cancels siblings in the batch; add explicit per-call error handling instead of relying on cascade-abort
## Pattern 7: SendMessage Agent Resume (CC 2.1.77)
Continue a previously spawned agent using `SendMessage`. CC 2.1.77 auto-resumes stopped agents — no error handling needed.
```python
# Spawn agent
Agent(subagent_type="backend-system-architect",
prompt="Design the API schema", name="api-designer")
# Later, continue the same agent with new context
SendMessage(to="api-designer", message="Now implement the schema you designed")
# CC 2.1.77: SendMessage auto-resumes stopped agents.
# No need to check agent state or handle "agent stopped" errors.
# NEVER use Agent(resume=...) — removed in 2.1.77.
```
## Pattern 8: /loop Skill Chaining (CC 2.1.71)
`/loop` runs a prompt or skill on a recurring interval — session-scoped, dies on exit, 3-day auto-expiry. Unlike `CronCreate` (agent-initiated), `/loop` is user-invoked and can chain other skills.
```text
# 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}`
## Rules
| 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 |
## References
Load on demand with `Read("${CLAUDE_SKILL_DIR}/references/<file>")`:
| File | Content |
|------|---------|
| `mcp-detection.md` | ToolSearch probe pattern + capability map |
| `handoff-schema.md` | JSON schema for `.claude/chain/*.json` |
| `checkpoint-resume.md` | state.json schema + resume protocol |
| `worktree-agent-pattern.md` | `isolation: "worktree"` usage guide |
| `cron-monitoring.md` | CronCreate patterns for post-task health |
| `experiment-journal.md` | Append-only TSV log for try/measure/keep-or-discard cycles |
| `progressive-output.md` | Progressive output with run_in_background |
| `sendRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.