diff --git a/CLAUDE.md b/CLAUDE.md index 61ae88c..2c20c13 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,7 +12,7 @@ plugins/ llm-security/ v6.0.0 — Security scanning, auditing, threat modeling ms-ai-architect/ v1.8.0 — Microsoft AI architecture (Cosmo Skyberg persona) okr/ v1.0.0 — OKR guidance for Norwegian public sector - ultraplan-local/ v2.1.0 — Brief, research, plan, execute (four-command pipeline) + ultraplan-local/ v2.2.0 — Brief, research, architect, plan, execute (five-command pipeline) ``` Hvert plugin er selvstendig med egen CLAUDE.md, README, hooks, agents og commands. diff --git a/README.md b/README.md index 021f218..eb8b448 100644 --- a/README.md +++ b/README.md @@ -61,28 +61,31 @@ Key commands: `/config-audit posture`, `/config-audit feature-gap`, `/config-aud --- -### [Ultra {brief | research | plan | execute} - local](plugins/ultraplan-local/) `v2.1.0` +### [Ultra {brief | research | architect | plan | execute} - local](plugins/ultraplan-local/) `v2.2.0` -Deep requirements gathering, research, implementation planning, and self-verifying execution with specialized agent swarms, adversarial review, and failure recovery. +Deep requirements gathering, research, Claude Code feature matching, implementation planning, and self-verifying execution with specialized agent swarms, adversarial review, and failure recovery. -Four commands, one pipeline with clear division of labor: +Five commands, one pipeline with clear division of labor: - **`/ultrabrief-local`** — Capture intent. Dynamic, quality-gated interview: a section-driven completeness loop (Phase 3) followed by a `brief-reviewer` stop-gate (Phase 4, max 3 review iterations). Required sections must reach an initial-signal gate AND pass review across completeness, consistency, testability, scope clarity, and research-plan validity before `brief.md` is written. Identifies research topics with copy-paste-ready `/ultraresearch-local` commands. Optional auto-orchestration runs research + planning in foreground. Always interactive. - **`/ultraresearch-local`** — Gather context. Deep multi-source research with triangulation: 5 local agents + 4 external agents + Gemini bridge, producing structured briefs with confidence ratings. Makes no build decisions. -- **`/ultraplan-local`** — Transform intent into an executable contract. Per-step YAML manifests (`expected_paths`, `commit_message_pattern`, `bash_syntax_check`). Plan-critic is a hard gate on manifest quality. Requires a task brief as input (`--brief` or `--project`). +- **`/ultra-cc-architect-local`** *(optional, v2.2)* — Match Claude Code features to the task. Reads `brief.md` + `research/*.md`, consults a seeded CC-feature catalog skill (hooks, subagents, skills, output styles, MCP, plan mode, worktrees, background agents), and produces `architecture/overview.md` with brief-anchored rationale plus `architecture/gaps.md` with issue-ready drafts for missing catalog entries. Hallucination gate (enforced by `architecture-critic`) blocks proposals for features not covered by the catalog. +- **`/ultraplan-local`** — Transform intent into an executable contract. Per-step YAML manifests (`expected_paths`, `commit_message_pattern`, `bash_syntax_check`). Plan-critic is a hard gate on manifest quality. Requires a task brief as input (`--brief` or `--project`). Auto-discovers the architecture note when present and cross-references its `cc_features_proposed` against exploration findings. - **`/ultraexecute-local`** — Execute the contract disciplined. Manifest-based verification, independent Phase 7.5 audit from git log + filesystem (ignores agent bookkeeping), Phase 7.6 bounded recovery dispatch for missing steps. Step 0 pre-flight catches sandbox push-denial before any work. `--validate` mode offers a fast schema-only sanity-check between planning and execution. -All artifacts land in one project directory: `.claude/projects/{YYYY-MM-DD}-{slug}/` contains `brief.md`, `research/NN-*.md`, `plan.md`, `sessions/`, and `progress.json`. `--project
+- **Proposed resolution**:+ +#### Gap 2 — ... + +### Out-of-scope requirements +- : why it is not a CC-feature gap +- ... + +### Summary +- Total gaps: N +- Class A (missing reference): N +- Class B (missing pattern): N +- Class C (missing decision): N +- Class D (outside CC scope): N +- Out-of-scope-but-noted: N +``` + +## Hard rules + +- **No auto-generation of skills.** Your output is draft issues, not + skill files. Skill-factory (a separate later process) handles + generation. +- **No auto-creation of issues.** The user decides whether to post any + gap as a real issue. +- **Gap ≠ error.** A gap is a known unknown, not a criticism of the + brief. Tone: neutral, informative. +- **Do not duplicate feature-matcher.** Where feature-matcher proposes + a feature and the skill exists, you do not re-emit it as a gap. +- **Do not hallucinate features.** Only use `cc_feature` values from + SKILL.md's canonical list. +- **Privacy.** Do not echo secrets from brief or research. +- **Honesty.** If there are no gaps, say "No coverage gaps identified + for this task." with a short justification. An empty gaps list is + valid output. diff --git a/plugins/ultraplan-local/agents/planning-orchestrator.md b/plugins/ultraplan-local/agents/planning-orchestrator.md index 22acf9a..3535635 100644 --- a/plugins/ultraplan-local/agents/planning-orchestrator.md +++ b/plugins/ultraplan-local/agents/planning-orchestrator.md @@ -66,6 +66,12 @@ You will receive a prompt containing: - **Research briefs** (optional) — paths to research briefs. Includes both auto-discovered `{project_dir}/research/*.md` files and any explicit briefs passed via `--research`. Read each brief before launching exploration agents. +- **Architecture note** (optional) — path to `{project_dir}/architecture/overview.md` + produced by the optional `/ultra-cc-architect-local` command. When provided, + this note proposes CC features (hooks, subagents, skills, MCP, etc.) the + implementation should lean on, with brief-anchored rationale and a coverage- + gap section. Missing file is fine — this is additive context, not a + requirement. Value is either an absolute path or `"none"`. Read the brief file first. It is the contract that bounds your work. Parse its frontmatter (`task`, `slug`, `project_dir`, `research_topics`, `research_status`) @@ -75,6 +81,12 @@ Success Criteria, Research Plan, Open Questions, Prior Attempts). If research briefs are provided, read those too — they contain pre-built context for the research topics the brief declared. +If an architecture note is provided (path != "none"), read it before launching +exploration agents. Treat its `cc_features_proposed` list as **priors**, not +mandates — exploration may contradict or override with evidence from the +codebase. Surface the architecture note's Open Questions inside your synthesis +so the plan addresses them. + ## Your workflow Execute these phases in order. Do not skip phases. @@ -183,8 +195,15 @@ Synthesize all findings: 6. **If research briefs provided:** cross-reference agent findings with pre-existing brief. Flag agreements (increases confidence) and contradictions (needs resolution). Incorporate brief recommendations into planning context. -7. Note remaining gaps as explicit assumptions -8. **Map brief sections → plan sections:** +7. **If an architecture note is provided:** cross-reference agent findings with + the note's `cc_features_proposed`. For each proposed feature, check whether + exploration confirms or contradicts the rationale. Proposed features that the + codebase already uses well → adopt in plan. Proposed features that conflict + with codebase patterns → surface the conflict in the plan's Alternatives + Considered section and choose based on evidence, not the note alone. Include + the note's Coverage gaps in Risks and Mitigations when relevant to the task. +8. Note remaining gaps as explicit assumptions +9. **Map brief sections → plan sections:** - Brief Intent → plan Context (motivation paragraph) - Brief Goal → plan Context (end state) - Brief Constraints/Preferences/NFRs → inputs to Implementation Plan decisions diff --git a/plugins/ultraplan-local/commands/ultra-cc-architect-local.md b/plugins/ultraplan-local/commands/ultra-cc-architect-local.md new file mode 100644 index 0000000..c67630c --- /dev/null +++ b/plugins/ultraplan-local/commands/ultra-cc-architect-local.md @@ -0,0 +1,376 @@ +--- +name: ultra-cc-architect-local +description: Match brief+research against available Claude Code features; produce architecture note with explicit gaps +argument-hint: "--project [--fg | --quick | --no-gaps]" +model: opus +allowed-tools: Agent, Read, Glob, Grep, Write, Edit, Bash, AskUserQuestion +--- + +# Ultra CC Architect Local v1.0 + +Valgfri pipeline-kommando som matcher oppgavens behov (brief + +research) mot tilgjengelige Claude Code-features (Hooks, Subagents, +Skills, Output Styles, MCP, Plan Mode, Worktrees, Background Agents) +og produserer et arkitekturnotat med eksplisitt gap-seksjon. + +Pipelinen er 5-stegs når denne kommandoen er med: + +``` +/ultrabrief-local → brief.md +/ultraresearch-local → research/*.md +/ultra-cc-architect-local → architecture/overview.md + gaps.md (this command) +/ultraplan-local → plan.md +/ultraexecute-local → execution +``` + +**Designprinsipp — selvlærende, men ikke autonom.** Kommandoen leser +en kuratert skill-katalog (`skills/cc-architect-catalog/`) med seed- +skills for hver CC-feature. Katalogen utvides over tid av en egen +skill-factory (separat utviklingsprosess). Arkitekturnotatet er et +forslag — brukeren godkjenner før plan-fasen. + +**Pipeline-integrasjon.** `/ultraplan-local` oppdager automatisk +`{project_dir}/architecture/overview.md` og bruker feature-forslagene +som priors (ikke mandater) under exploration og planning. + +## Phase 1 — Parse mode and validate input + +Parse `$ARGUMENTS` for flags. Ordered precedence: + +1. **`--project `** (PÅKREVD) — les `{dir}/brief.md` og + auto-oppdag `{dir}/research/*.md`. Skriv til `{dir}/architecture/`. + Hvis `{dir}` eller `{dir}/brief.md` mangler: + ``` + Error: project directory not initialized. Run /ultrabrief-local first. + Missing: {dir}/brief.md + ``` + Sett **project_dir = {dir}**, **brief_path = {dir}/brief.md**. + Sett **architecture_dir = {dir}/architecture/** — opprettes i + Phase 2 hvis den mangler. + +2. **`--fg`** — foreground. Alle faser inline. Default er background + via `architect-orchestrator`. Sett **execution = foreground**. + +3. **`--quick`** — hopp over Phase 6 (adversarial review). Sett + **mode = quick**. + +4. **`--no-gaps`** — utelat `gaps.md` (gap-seksjonen beholdes internt + i `overview.md`). Sett **mode_suffix = no-gaps**. (Kan kombineres + med `--quick`.) + +5. Hvis `--project` mangler: vis usage og stopp: + +``` +Usage: /ultra-cc-architect-local --project [--fg] [--quick] [--no-gaps] + +A project directory is required. Run /ultrabrief-local first to create one. + +Modes: + default Background via architect-orchestrator → overview.md + gaps.md + --fg All phases in foreground (blocks session) + --quick Skip adversarial review (no architecture-critic pass) + --no-gaps Do not write gaps.md (gap-section stays inside overview.md) + +Examples: + /ultra-cc-architect-local --project .claude/projects/2026-04-18-jwt-auth + /ultra-cc-architect-local --project .claude/projects/2026-04-18-jwt-auth --fg + /ultra-cc-architect-local --project .claude/projects/2026-04-18-jwt-auth --fg --quick + +Pipeline position (5-steg): + /ultrabrief-local → /ultraresearch-local → /ultra-cc-architect-local + → /ultraplan-local → /ultraexecute-local +``` + +Ikke fortsett forbi dette steget hvis `--project` mangler. + +### Les briefen + +Les `{brief_path}` og parse frontmatter. Hent: +- `task` — one-liner for stats +- `slug` — brukes i overview-frontmatter +- `project_dir` — hvis satt, kryssjekk mot flag; mismatch → advarsel, + men bruk flag-verdien +- `brief_quality` — `complete | partial`. Partial briefer er lovlige; + noter i overview.md under "Open questions". + +### Scan research/ + +Glob `{project_dir}/research/*.md`. Lagre liste som +**research_paths**. Zero research er lovlig. + +### Rapporter detektert modus + +``` +Mode: {default | foreground}{, quick}{, no-gaps} +Project: {project_dir} +Brief: {brief_path} ({brief_quality}) +Research: {N} files detected +``` + +## Phase 2 — Background transition + +**Hvis execution = foreground:** hopp over denne fasen. Fortsett inline +fra Phase 3. + +**Hvis execution = default (background):** + +Opprett `{architecture_dir}` hvis den ikke eksisterer (`mkdir -p`). + +Launch the **architect-orchestrator** agent with this prompt: + +``` +Brief file: {brief_path} +Project dir: {project_dir} +Architecture dir: {architecture_dir} +Research briefs: {comma-separated research_paths, or "none"} +Skill catalog root: ${CLAUDE_PLUGIN_ROOT}/skills/cc-architect-catalog +Plugin root: ${CLAUDE_PLUGIN_ROOT} +Mode: {default | quick}{, no-gaps if set} + +Read the brief and every research brief. Execute your full workflow. +Write overview.md to the architecture dir. Write gaps.md unless mode +includes no-gaps. +``` + +Launch via Agent-tool med `run_in_background: true`, `subagent_type: +architect-orchestrator`. + +Deretter output til bruker og **stopp ditt svar**: + +``` +Background architecture run started via architect-orchestrator. + + Project: {project_dir} + Brief: {brief_path} + Research: {N} briefs + Output: {architecture_dir}/overview.md (+ gaps.md) + +You will be notified when the architecture note is ready. +You can continue working on other tasks in the meantime. +``` + +Ikke vent på orchestratoren. Ikke fortsett til Phase 3. +architect-orchestrator håndterer Phase 3–7 autonomt. + +--- + +**Alt under denne linjen kjører enten i foreground-modus eller inne i +background-agenten. Instruksjonene er identiske uavhengig av kontekst.** + +--- + +## Phase 3 — Read inputs and audit the catalog + +Les briefen i sin helhet. Hent Intent, Goal, Non-Goals, Constraints, +Preferences, NFRs, Success Criteria, Research Plan, Open Questions, +Prior Attempts. + +Les hver research-brief sitt Executive Summary + Recommendation +(2–3 setninger per brief). + +Les `${CLAUDE_PLUGIN_ROOT}/skills/cc-architect-catalog/SKILL.md` for å +lære taxonomy og lag-modellen. + +Glob `${CLAUDE_PLUGIN_ROOT}/skills/cc-architect-catalog/*.md` +(unntatt `SKILL.md`). Hvis glob returnerer null filer: sett +`catalog_empty = true` (ikke feil — `feature-matcher` har fallback). + +Opprett `{architecture_dir}` hvis den ikke eksisterer. + +## Phase 4 — Feature matching (parallel swarm) + +Launch to agents i parallell, i én melding: + +- **feature-matcher** (model: sonnet). Prompt med brief_path, + research_paths, catalog_root, project_dir. +- **gap-identifier** (model: sonnet). Samme input. Jobber uavhengig + av feature-matcher (off briefen og katalogen direkte). + +Pass konkrete filstier, ikke inlined content. + +Etter begge returnerer: + +- `fallback_used = true` hvis `catalog_empty` eller feature-matcher + rapporterer det. +- Trekk ut feature-liste, rationales, confidences, integration-noter + fra feature-matcher. +- Trekk ut gaps, out-of-scope, katalog-dekningsstats fra + gap-identifier. + +## Phase 5 — Synthesize architecture/overview.md + +Skriv `{architecture_dir}/overview.md`. + +**Frontmatter:** + +```yaml +--- +task: +slug: +created: +source_brief: +source_research: [ ] +skills_consulted: [
] +cc_features_proposed: [
] +review_status: pending +--- +``` + +**Seks seksjoner i denne rekkefølgen:** + +1. **Context** — 3 setninger. Paraphrase brief Intent + Goal. +2. **Proposed CC features** — tabell: Feature | Rationale (brief + anchor) | Supporting skill | Confidence. Én rad per foreslått + feature. Behold primary/secondary/fallback-grupperingen som + underseksjoner hvis feature-matcher leverte dem. +3. **Feature composition** — hvordan features samspiller. Sekvens, + konflikter, delte tilstander, fallbacks. 3–6 bullets. +4. **Coverage gaps identified** — **ALLTID tilstede**, også når tom. + Hvis tom, skriv "No coverage gaps identified — catalog covers all + features this task requires." Hvis ikke-tom, oppsummer hver gap i + én linje. Full issue-draft-tekst går til `gaps.md` i Phase 7 (med + mindre `--no-gaps`). +5. **Alternatives considered** — minst én alternativ feature- + kombinasjon med grunn for avvisning. Rationale må referere + briefen. +6. **Open questions** — hva plan-fasen må avgjøre. Inkluder evt. + uløste tradeoffs fra feature-matcher + briefens egne Open + Questions. + +## Phase 6 — Adversarial review + +**Hvis mode = quick:** hopp over denne fasen. Sett +`critic_verdict = "SKIPPED"` og `guardian_verdict = "SKIPPED"`. +Fortsett til Phase 7. + +Launch to reviewere i parallell: + +- **architecture-critic** (model: sonnet). Input: overview.md, + brief_path, research_paths, catalog_root. +- **scope-guardian** (model: sonnet). Prompt **eksplisitt**: "The + artifact under review is an architecture note (not an implementation + plan). Verify that the proposed features align with brief + requirements. Flag scope creep (features not justified by the brief) + and scope gaps (brief requirements no proposed feature addresses)." + +Håndter verdikter: + +- **PASS + ALIGNED** — note ferdig. `review_status: approved`. +- **REVISE** fra critic — revidér notatet i plass, adresser hver + major finding. Re-launch architecture-critic én gang. Fortsatt + REVISE → emit findings som `## Review notes`-seksjon nederst, + fortsett. Ikke loop. +- **BLOCK** fra critic — revidér for å fjerne blocker (typisk + hallucinert feature eller manglende anchor). Re-launch én gang. + Fortsatt BLOCK → `review_status: needs_rewrite`, surface findings + i Open Questions. +- **CREEP / GAP / MIXED** fra guardian — append `## Scope review`- + subseksjon med funnene. Ikke re-synthesize med mindre combined med + critic REVISE/BLOCK. + +Oppdater `review_status` i frontmatter etter resultatet. + +## Phase 7 — Present, write gaps.md, stats + +**gaps.md** — skrives med mindre `--no-gaps`. Format: + +```markdown +# Coverage gaps —
+ +These are issue-ready drafts. Copy to the project's git host manually +when you decide a gap warrants tracking. No auto-creation. + +--- + + + +--- + + + +... +``` + +Zero gaps: skriv en-liner ("No coverage gaps identified.") slik at +filstaten er deterministisk. + +**Stats** — append én linje til +`${CLAUDE_PLUGIN_DATA}/ultra-cc-architect-local-stats.jsonl`: + +```json +{ + "ts": " ", + "task": " ", + "mode": " ", + "slug": " ", + "project_dir": " ", + "architecture_path": " /overview.md", + "gaps_path": " /gaps.md | null>", + "skills_catalog_size": , + "skills_consulted": , + "features_proposed": , + "gaps_identified": , + "critic_verdict": " ", + "guardian_verdict": " ", + "fallback_used": +} +``` + +Hvis `${CLAUDE_PLUGIN_DATA}` ikke er satt eller ikke skrivbar, skip +stats silently. + +**Summary til brukeren:** + +``` +## Ultra-CC-Architect Complete + +**Task:** +**Project:** +**Architecture note:** /overview.md +**Gaps draft:** /gaps.md | skipped (--no-gaps) +**Features proposed:** N (primary: N, secondary: N, fallback: N) +**Gaps identified:** N +**Review:** / + +### Primary features +- : +- : ... + +### Top gaps (if any) +- +- + +Next step: /ultraplan-local --project +(the architecture note is auto-discovered as extra context) +``` + +## Hard rules + +- **Catalog is ground truth.** Hver foreslått feature må komme fra + katalogens `cc_feature`-taxonomy eller feature-matcher's dokumenterte + fallback-liste. `architecture-critic` blokkerer hallucinated + features. +- **Brief is anchor.** Hver foreslått feature må sitere en konkret + brief-seksjon (Intent/Goal/Constraint/NFR/Success Criterion). Features + uten anchor fjernes under review. +- **Gap ≠ error.** "Coverage gaps identified"-seksjonen er **alltid** + til stede — tom eller full. Brief §4.5 ("Mangel ≠ feil"). +- **No auto-issue-creation.** Gaps er drafts i `gaps.md`. Brukeren + avgjør hva som postes. +- **Sonnet for sub-agents.** Opus kun for orchestrator og hoved- + kommandoen. +- **Privacy.** Aldri logg secrets, tokens, credentials fra brief, + research eller katalog. +- **Idempotent.** Re-kjøring overskriver `overview.md` og `gaps.md`. + Stats-linjene akkumuleres. +- **Graceful degradation.** Tom katalog → fallback-liste. Manglende + research → jobb kun fra brief. Partial brief → noter i Open + Questions. +- **Additiv i pipeline.** `/ultraplan-local` oppdager overview.md + automatisk men må fungere uendret om filen mangler. +- **No third-party content copied** (brief §4.4). Seed-skills er + håndskrevet. Fremtidig skill-factory-output håndterer IP-hygiene + separat. +- **No n-gram computation here.** Feltet `ngram_overlap_score` + respekteres (ikke-null > threshold → flagge), men beregnes av + skill-factory, ikke denne kommandoen. diff --git a/plugins/ultraplan-local/commands/ultraplan-local.md b/plugins/ultraplan-local/commands/ultraplan-local.md index 18031c3..2d74787 100644 --- a/plugins/ultraplan-local/commands/ultraplan-local.md +++ b/plugins/ultraplan-local/commands/ultraplan-local.md @@ -62,6 +62,10 @@ Parse `$ARGUMENTS` for mode flags. Order of precedence: ``` - Set **project_dir = {dir}**, **brief_path = {dir}/brief.md**. - Set **has_research_brief = true** if `{dir}/research/*.md` matches ≥ 1 file. + - Set **has_architecture_note = true** if `{dir}/architecture/overview.md` exists. + If set, **architecture_note_path = {dir}/architecture/overview.md**. Produced by + the optional `/ultra-cc-architect-local` command. Missing file is fine — this is + additive discovery, not a requirement. 4. **`--brief `** — extract the brief path. If the file does not exist: ``` @@ -323,9 +327,12 @@ Mode: {default | quick} Plan destination: {plan destination} Plugin root: ${CLAUDE_PLUGIN_ROOT} Research briefs: {comma-separated list, or "none"} +Architecture note: {architecture_note_path or "none"} -Read the brief file and every research brief. Execute your full planning -workflow. Write the plan to the destination path. +Read the brief file and every research brief. If an architecture note is +provided, read it before launching exploration agents and treat its feature +proposals as priors (not mandates) — exploration may override with evidence. +Execute your full planning workflow. Write the plan to the destination path. ``` Launch the planning-orchestrator via the Agent tool with `run_in_background: true`. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/SKILL.md b/plugins/ultraplan-local/skills/cc-architect-catalog/SKILL.md new file mode 100644 index 0000000..d3b41e7 --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/SKILL.md @@ -0,0 +1,140 @@ +--- +name: cc-architect-catalog +description: Internal catalog for ultra-cc-architect-local — not invoked directly. Indexes CC-feature reference and pattern skills. +layer: manifest +cc_feature: meta +source: https://docs.claude.com/en/docs/claude-code +concept: catalog-index +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# CC Architect Catalog — Manifest + +This file is the catalog index consumed by the `feature-matcher` and +`gap-identifier` agents inside `/ultra-cc-architect-local`. It is NOT +intended to be auto-invoked by Claude Code's skill system — the +description above exists only so the skill loader has something to +display if it indexes this directory. + +## Purpose + +The catalog enumerates which Claude Code features the architect command +can reason about, and at which layer of abstraction. Each feature gets +one or more skill files in this directory. A skill is a self-contained +note about *one* feature at *one* layer. + +## Layers (frontmatter `layer` field) + +| Layer | Purpose | Kilde | +|-------|---------|-------| +| `reference` | Facts, API, syntax. What the feature *is*. | CC changelog, official docs | +| `pattern` | When and how to use it. Typical shapes, pitfalls. | Synthesized from practice | +| `decision` | Operational decision tree across features. | Synthesized. (No seeds yet.) | + +Lag representeres som frontmatter-felt, ikke mappestruktur. Rationale: +one feature can have skills at multiple layers without relocation, and +future skill-factory output can target a specific layer without moving +files. + +## Frontmatter contract (per skill file) + +Every skill file in this directory MUST have this frontmatter. The +fields are load-bearing for the architect command. + +```yaml +--- +name: # unique, kebab-case +description: # used by feature-matcher +layer: reference | pattern | decision +cc_feature: # see table below +source: # canonical upstream source +concept: # 3–6 word concept handle +last_verified: # when a human last checked against upstream +ngram_overlap_score: null # reserved for skill-factory IP-hygiene +review_status: approved | pending | auto-merged +--- +``` + +`ngram_overlap_score` is reserved. This command respects it (will flag +non-null values > threshold) but does not compute it. Skill-factory (a +separate later process) populates that field. + +`review_status: approved` is the default for seeds (approved by +construction — handwritten, no third-party text copied). Future +skill-factory output will start as `pending` (channel 2) or +`auto-merged` (channel 1). + +## Canonical `cc_feature` values + +| Value | Coverage | +|-------|----------| +| `hooks` | Event hooks (UserPromptSubmit, PreToolUse, PostToolUse, Stop, Notification, SessionStart, etc.) | +| `subagents` | Task-tool sub-agents, delegation patterns | +| `skills` | Claude Code skill system (not Agent SDK skills) | +| `output-styles` | Output style configuration | +| `mcp` | Model Context Protocol servers and tools | +| `plan-mode` | Built-in plan mode | +| `worktrees` | Git worktree integration | +| `background-agents` | `run_in_background`, Monitor, long-running agents | +| `meta` | This manifest only — not a real feature | + +If a future skill covers a feature not in this list, add the row above +and surface the extension in the relevant CHANGELOG entry. + +## Current seed coverage (v2.2.0) + +| Feature | reference | pattern | decision | +|---------|-----------|---------|----------| +| hooks | hooks-reference | hooks-pattern | — | +| subagents | subagents-reference | subagents-pattern | — | +| skills | skills-reference | — | — | +| output-styles | output-styles-reference | — | — | +| mcp | mcp-reference | — | — | +| plan-mode | plan-mode-reference | — | — | +| worktrees | worktrees-reference | — | — | +| background-agents | background-agents-reference | — | — | + +Total: 10 seed skills, 8 features, 2 layers. Decision-layer is +intentionally empty — decisions cross features and require broader +synthesis than a single seed pass can provide. Skill-factory populates +decision-layer later. + +## How `feature-matcher` uses this file + +1. Read this file to learn the `cc_feature` taxonomy. +2. Glob the directory for `*.md` files (excluding SKILL.md). +3. Parse each skill's frontmatter. +4. For each feature mentioned in the brief or research, match against + `cc_feature` field. Prefer `pattern` over `reference` when both exist + (pattern is richer). +5. When no skill exists for a mentioned feature, fall back to the + hardcoded minimum-list inside the `feature-matcher` prompt and mark + the gap in stats (`fallback_used: true`). + +## How `gap-identifier` uses this file + +1. Collect every feature referenced in `feature-matcher`'s output. +2. For each feature, check whether the catalog has at least one skill at + each expected layer (reference always; pattern when complexity + warrants; decision for cross-feature choices). +3. Emit a gap entry for every missing (feature × layer) pair. +4. Label with `skill-layer: ` and `cc-feature: `. + +## Non-goals for this file + +- No skill-factory logic. That is a separate later process. +- No auto-discovery of new CC features. +- No n-gram computation. +- No triggering Claude Code auto-invocation (description deliberately + says "not invoked directly"). + +## Modification rules + +- Adding a new skill: create ` - .md` with the frontmatter + above and bump the coverage table in this file. +- Renaming `cc_feature` values: update both this file AND every skill + using the old value in the same commit. +- Removing a skill: document in CHANGELOG under the version that drops + it. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/background-agents-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/background-agents-reference.md new file mode 100644 index 0000000..604d5cc --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/background-agents-reference.md @@ -0,0 +1,106 @@ +--- +name: background-agents-reference +description: CC background agents — long-running subagents with run_in_background and Monitor for progress streaming. +layer: reference +cc_feature: background-agents +source: https://docs.claude.com/en/docs/claude-code/background-agents +concept: async-agents-and-monitoring +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Background Agents — Reference + +A background agent is a subagent launched with `run_in_background: +true`. The parent does not block on its return; instead, the harness +notifies the parent when the agent completes. Useful for long-running +exploration, orchestration, and work that overlaps with user activity. + +## Launching + +``` +Agent({ + description: "...", + subagent_type: "...", + prompt: "...", + run_in_background: true +}) +``` + +The Agent tool returns a handle (agent ID / name). The parent +continues its turn; no wait. + +## Monitoring + +Two complementary tools work with background agents: + +- **Monitor** — streams updates from a named background process. Each + event line arrives as a notification. Used for long-running Bash + processes (and, in newer builds, some agent streaming paths). +- **Completion notifications** — the harness posts a message to the + parent when the background agent finishes. The parent sees it as a + system-reminder / notification on its next turn. + +## When background is worth it + +- **Overlapping work** — orchestrator runs 30+ minutes of research + while the user continues coding. Without background, the user is + blocked the whole time. +- **Parallel waves** — wave N of sessions running concurrently; the + parent collects results as they arrive. +- **Long-running processes** — an agent waiting on a build, test run, + or deployment. + +## When background hurts + +- **Short tasks** — agent returns in 10 seconds; making it async adds + overhead for no gain. +- **Tight coupling** — if the parent needs the result before doing + anything else, background is just foreground with extra steps. +- **Unbounded token spend** — a background agent with no budget + signaling can run until it hits limits. Cap explicitly. + +## Common shapes + +### Shape A: Orchestrator handoff + +Parent interviews user, writes a spec, launches a background +orchestrator with the spec path. Parent exits its turn; orchestrator +takes over for the heavy phases. + +Used by: `ultraplan-local`, `ultraresearch-local`. + +### Shape B: Parallel waves + +Parent decomposes work into N independent sessions, launches them all +in parallel with `run_in_background: true`, then synthesizes returns +as they arrive. + +Used by: `ultraplan-local --decompose` execution. + +### Shape C: Watcher + +A background agent polls a process (build, test, deploy) and reports +status changes. Uses Monitor for streaming. + +## Pitfalls + +- **Lost context** — if the parent conversation ends before the + background agent completes, the result may be orphaned. Persist to + disk, not memory. +- **Notification fatigue** — too many background agents = too many + reminders interrupting the parent's flow. +- **Debugging** — background agents run out of the user's view; their + failures can be silent. Log to files, not just return messages. + +## Composition + +- Background + worktrees: the canonical pattern for parallel + implementation — each background agent in its own worktree, no + clashes. +- Background + subagents: an orchestrator IS a subagent; it in turn + can launch its own subagents (foreground inside the orchestrator's + context, or further background). +- Background + hooks: hooks fire inside the background agent's tool + calls, same as foreground. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/hooks-pattern.md b/plugins/ultraplan-local/skills/cc-architect-catalog/hooks-pattern.md new file mode 100644 index 0000000..2a19e99 --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/hooks-pattern.md @@ -0,0 +1,89 @@ +--- +name: hooks-pattern +description: When to choose hooks over prompts or subagents, and common hook shapes that work. +layer: pattern +cc_feature: hooks +source: https://docs.claude.com/en/docs/claude-code/hooks +concept: hooks-decision-and-shapes +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Hooks — Pattern + +## When to reach for a hook + +Use hooks when the behavior must hold even if Claude is prompt-injected, +distracted, or adversarial. Hooks are outside the model's control loop — +Claude cannot talk its way past them. + +Good fits: + +- **Hard prohibitions** — "never run `rm -rf /`", "never push to main + without a commit signature", "never read files outside this repo". +- **Deterministic context injection** — always show git status at + session start; always inject the current sprint's tasks. +- **Audit trails** — log every Bash call, every file write, outside the + conversation context so it survives `/clear`. +- **Compliance boundaries** — redact secrets from transcripts; block + tool calls that would leak PII. + +Bad fits: + +- Behavior that requires judgment ("should this test run?") — that's a + subagent call. +- Heuristics that drift ("mostly block, sometimes allow") — a hook that + frequently second-guesses itself is a sign the rule belongs in a + prompt or skill. +- Anything that needs to read lots of conversation history — hooks see + a payload, not the full context. + +## Common shapes + +### Shape A: PreToolUse deny + +A small script that reads `tool_input`, matches a pattern, and exits +with a `block` decision. Latency: a few ms. Used for command denylists, +path guards, secrets scanners. + +### Shape B: UserPromptSubmit context injection + +A script that reads the prompt, computes context (e.g., recent git log, +active TODO list), and emits JSON with an `additionalContext` field. +The harness adds that context to the prompt before Claude sees it. + +### Shape C: Stop hook with reminder + +A script that runs when Claude finishes a turn. Checks for uncommitted +work, surfaces it as a notification. Non-blocking. + +### Shape D: SessionStart status + +Runs once per session. Prints repo metadata (branch, open PRs, recent +commits) so every new session starts with shared context. + +## Pitfalls + +- **Slow hooks compound.** A 500 ms PreToolUse hook run 50 times per + session adds 25 seconds of latency. +- **Hooks without error handling crash the turn.** A hook that exits + non-zero on an edge case blocks real work. Default to exit 0 with a + logged warning. +- **Shell-injection in hook scripts.** A hook that interpolates + `tool_input.command` into `bash -c` is itself a security hole. Parse + inputs; never interpolate unescaped. +- **Hooks can leak secrets into transcripts** if their output mentions + env-var values. Scrub before emitting. +- **Cross-platform scripts.** A hook that assumes bash 4 or GNU sed + breaks on macOS. Prefer Node.js, Python, or POSIX sh. + +## Composition with other features + +- Hooks + subagents: a hook can delegate the "should this be blocked" + question to a subagent when the decision needs judgment. Cost: a full + model call per hook invocation — use sparingly. +- Hooks + MCP: a hook can call out to an MCP-exposed tool for policy + lookup. Latency depends on transport. +- Hooks + plan mode: hooks fire during plan mode too. Useful for + enforcing "no writes while planning". diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/hooks-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/hooks-reference.md new file mode 100644 index 0000000..0681142 --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/hooks-reference.md @@ -0,0 +1,85 @@ +--- +name: hooks-reference +description: CC hooks API — event types, payload shapes, exit codes, and where hooks run. +layer: reference +cc_feature: hooks +source: https://docs.claude.com/en/docs/claude-code/hooks +concept: hooks-api-surface +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Hooks — Reference + +Hooks are shell commands or scripts that the Claude Code harness runs +in response to events. They give the harness — not Claude — the final +say on whether a tool call, prompt, or session action proceeds. Claude +cannot bypass a hook by prompting itself; the hook runs outside the +model's control loop. + +## Event types + +- **UserPromptSubmit** — fires when the user sends a prompt. Runs before + Claude processes it. Common use: inject extra context, reject + disallowed prompts. +- **PreToolUse** — fires before a tool call. Can deny the call. Common + use: block destructive commands, require confirmation. +- **PostToolUse** — fires after a tool call completes. Sees the result. + Common use: log side effects, redact output, trigger follow-up work. +- **Stop** — fires when the agent finishes a turn. Common use: commit + reminders, session summaries. +- **Notification** — fires when Claude wants to show the user a + notification (e.g., long-running task). +- **SessionStart** — fires when a session begins. Common use: print + repo state, inject context. + +## Payload shape + +Hooks receive a JSON payload on stdin. Common fields: + +- `session_id` — the current session identifier. +- `transcript_path` — path to the conversation transcript. +- `cwd` — current working directory. +- `tool_name` (PreToolUse, PostToolUse) — which tool is running. +- `tool_input` (PreToolUse) — the arguments to the tool. +- `tool_response` (PostToolUse) — the tool's result. +- `prompt` (UserPromptSubmit) — the submitted text. + +Exact field availability depends on event type. Read the payload JSON +rather than assuming a schema. + +## Exit codes and control + +Hooks communicate back via exit code and stdout JSON: + +- Exit 0, no stdout → proceed normally. +- Exit 0, stdout JSON with `decision` field → harness honors the + decision (e.g., `{"decision": "block", "reason": "..."}`). +- Exit non-zero → harness treats as a denial or error, depending on + event and hook type. + +Some hook types support structured output beyond deny/allow (e.g., +adding context to the prompt). Details differ per event. + +## Where hooks live + +- Project hooks: `.claude/settings.json` `hooks` field, paths relative + to project. +- User hooks: `~/.claude/settings.json` (global). +- Plugin hooks: packaged with a plugin, activated when the plugin is + enabled. + +Hooks run in the harness process's shell, not in Claude's tool-use +sandbox. They can spawn subprocesses, read environment variables, +and touch the filesystem. + +## Implications for architecture + +- Hooks are the mechanism for **deterministic policy** (things that + must always or never happen, regardless of what Claude decides). +- Hooks are load-bearing for security: prompt-injection-resistant + defenses live here, not in prompts. +- Hooks add latency to every tool call they gate — keep them fast. +- Hook output is part of the context window; verbose hooks burn + tokens quickly. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/mcp-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/mcp-reference.md new file mode 100644 index 0000000..539ce0f --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/mcp-reference.md @@ -0,0 +1,72 @@ +--- +name: mcp-reference +description: Model Context Protocol — external tools and resources exposed to Claude via MCP servers. +layer: reference +cc_feature: mcp +source: https://docs.claude.com/en/docs/claude-code/mcp +concept: mcp-tool-protocol +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# MCP — Reference + +Model Context Protocol (MCP) is the protocol Claude Code uses to talk +to external tool servers. An MCP server advertises *tools* and +*resources*; Claude Code surfaces them to Claude as callable tools. + +## Architecture + +- **MCP server** — a process (local or remote) that implements the + protocol. Can be written in any language. Communicates over stdio, + HTTP, or WebSocket. +- **Transport** — stdio (local subprocess), SSE/HTTP (remote), or + WebSocket. Stdio is the default for local servers. +- **Tools** — callable functions the server exposes. Each has a name, + description, and JSON schema for inputs. +- **Resources** — readable entities the server exposes (files, + database rows, API responses). Addressed by URI. +- **Prompts** — optional; MCP can expose templated prompts. + +## Configuration + +MCP servers are declared in: + +- `.mcp.json` — project-level MCP config. +- `~/.claude.json` or equivalent — user-level. +- Plugin-bundled — a plugin can ship its own MCP server. + +Each entry specifies command, args, transport, and optional auth. + +## Tool naming + +Tools from MCP servers appear to Claude with a namespaced name: +`mcp__ __ `. This keeps names collision-free +across servers. + +## Permissions + +- `allowed-tools` in settings or plugin frontmatter can include MCP + tools by full name. +- Some MCP servers require OAuth or API keys; those are configured in + the server's own config, not Claude's. + +## Common uses + +- Exposing internal APIs to Claude without hand-wrapping them (one + generic MCP server → many tools). +- Cross-language tool servers (Python tool called from Claude Code + running in Node). +- Sandboxed access to external services with explicit scoping. + +## Failure modes + +- Server not running → tool calls fail; Claude sees an error string. +- Server misbehaves → tool returns wrong schema; Claude may retry or + hallucinate. +- Authentication drift → 401s look like transient errors; diagnose by + checking the server directly. +- Security: an MCP server runs with the permissions of its own + process. A malicious server is a supply-chain risk; audit before + enabling. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/output-styles-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/output-styles-reference.md new file mode 100644 index 0000000..abe34fa --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/output-styles-reference.md @@ -0,0 +1,58 @@ +--- +name: output-styles-reference +description: CC output styles — configurable response shape, tone, length, and formatting baselines. +layer: reference +cc_feature: output-styles +source: https://docs.claude.com/en/docs/claude-code/output-styles +concept: output-style-config +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Output Styles — Reference + +Output styles let a user or plugin shape how Claude Code responds: +length defaults, formatting preferences, tone, verbosity. They apply +across the session rather than needing to be re-stated per prompt. + +## Where they live + +- **Built-in styles** — shipped with the CLI. +- **Custom styles** — directory with a manifest describing the style. +- **Selection** — the user sets an active style via settings or a + `/style` command. The style is injected into Claude's system context. + +## What a style can control + +- Default response length baseline ("keep responses ≤ 100 words + unless detail is required"). +- Formatting rules (markdown vs plain, code-block conventions). +- Tone ("terse", "pedagogical", "adversarial"). +- Domain voice (Norwegian for dialog, English for code — a project + convention encoded as a style). + +## What a style cannot control + +- Tool permissions (that is `allowed-tools` / `settings.json`). +- Hooks (those are harness-level). +- Agent system prompts (those come from agent definitions). + +## When to use a custom style + +- The project has a persistent communication convention that should + hold across every session (e.g., "never use emojis"). +- Multiple users share the project and want consistent output. +- A skill's prompts would otherwise have to restate formatting rules + each time. + +## When not to + +- For per-task formatting needs — use the prompt instead. +- For rules that must hold against prompt injection — use hooks. + +## Practical shape + +A minimal custom style is a markdown or plain-text block listing the +conventions. Claude treats it as top-of-system guidance. Keep it +short: long styles crowd out the task. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/plan-mode-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/plan-mode-reference.md new file mode 100644 index 0000000..72874bf --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/plan-mode-reference.md @@ -0,0 +1,65 @@ +--- +name: plan-mode-reference +description: CC plan mode — read-only planning phase before implementation, with explicit user approval gate. +layer: reference +cc_feature: plan-mode +source: https://docs.claude.com/en/docs/claude-code/plan-mode +concept: planning-before-execution +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Plan Mode — Reference + +Plan mode is a built-in state where Claude operates read-only and +produces an implementation plan instead of executing it. The user +reviews the plan, then either approves it to transition to +implementation or iterates. + +## State machine + +1. **Plan mode entered** — user triggers it (Shift+Tab twice, `/plan`, + or harness-initiated) or Claude calls `EnterPlanMode`. +2. **Read-only operation** — Claude can read files, search, run + analysis. Writes, edits, and commits are blocked by the harness. +3. **Plan produced** — Claude presents a plan via `ExitPlanMode` or + equivalent. +4. **User reviews** — accepts, rejects, or iterates. +5. **Exit** — on acceptance, mode returns to normal (edits allowed). + +## What plan mode guarantees + +- No writes during the plan phase. Even if Claude tries, the harness + denies write tools. +- A structured handoff: the plan is a message the user sees before + anything happens. + +## What plan mode does not guarantee + +- Plan quality. Plan mode is a *gate*, not a *reviewer*. A bad plan + still passes if the user approves it. +- Scope locking. After exit, Claude can do whatever the new prompts + ask — plan mode is a phase, not a contract. + +## When to opt into plan mode + +- Tasks touching multiple files or modules where the order and file + list matter. +- Refactors where the first wrong edit is expensive to undo. +- Unfamiliar codebases where planning surfaces missing context. + +## When to skip plan mode + +- Single-file trivial changes. +- Tasks already specified by a detailed plan from another tool + (e.g., an `ultraplan-local` plan.md) — planning twice is waste. + +## Relationship to /ultra* planning + +- `/ultraplan-local` produces a *plan artifact* that outlives the + session. Plan mode produces an *in-conversation plan* that does not + survive `/clear`. +- They compose: use plan mode to sketch at session start, then run + `/ultraplan-local` to get the durable, reviewable, machine-readable + plan with manifests. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/skills-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/skills-reference.md new file mode 100644 index 0000000..1481131 --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/skills-reference.md @@ -0,0 +1,83 @@ +--- +name: skills-reference +description: CC skills — auto-invoked domain modules with SKILL.md, frontmatter triggers, and file-hierarchy discovery. +layer: reference +cc_feature: skills +source: https://docs.claude.com/en/docs/claude-code/skills +concept: skills-system +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Skills — Reference + +Claude Code's skill system is a way to package domain knowledge, +workflows, and supporting files so Claude can load them on demand. A +skill is a directory with a `SKILL.md` manifest and any auxiliary +files (scripts, templates, references). + +## Anatomy + +- **`SKILL.md`** — the entry point. Markdown file with YAML + frontmatter and a body. The frontmatter declares when the skill + triggers; the body is instructions Claude follows after loading. +- **Auxiliary files** — any files in the skill directory. Loaded on + demand (typically by Claude reading them when the body references + them). Common: `scripts/`, `templates/`, `references/`. + +## Frontmatter + +```yaml +--- +name: +description: +--- +``` + +The `description` is what Claude sees when deciding whether to invoke. +It should describe *when* to use the skill, not *what* it does. + +## Invocation + +- **Auto-invocation** — Claude loads the skill when the user's prompt + matches the description's triggers. The trigger model is implicit + (natural-language match), not regex. +- **Manual invocation** — the user types `/ ` and Claude + calls the Skill tool. +- **Never auto-invoked** — if the description explicitly says so + ("Internal catalog for X — not invoked directly"), Claude typically + respects the hint. + +## Discovery + +Skills are discovered from: + +- **Built-in skills** — shipped with the CLI. +- **Plugin skills** — packaged inside a plugin's `skills/` directory. +- **User skills** — `~/.claude/skills/`. +- **Project skills** — `.claude/skills/` inside the repo. + +The CLI surfaces available skills via `--allowedTools` and in the +system prompt. + +## Progressive disclosure + +Skills use progressive disclosure: + +1. Claude sees only the name + description at session start. +2. When a skill triggers, the body loads into context. +3. Files referenced by the body load only when Claude reads them. + +This keeps the baseline context small; depth is paid for on demand. + +## Relationship to other features + +- **Skills vs subagents** — a skill lives in the parent's context when + loaded. A subagent runs in its own context. Choose skill when the + context flows through; subagent when it should not. +- **Skills vs hooks** — hooks are deterministic harness-level rules. + Skills are context that Claude interprets. A skill cannot enforce; + only guide. +- **Skills vs MCP** — MCP exposes *tools*. Skills are *knowledge*. An + MCP tool + a skill that explains when to use it is a common pairing. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/subagents-pattern.md b/plugins/ultraplan-local/skills/cc-architect-catalog/subagents-pattern.md new file mode 100644 index 0000000..21a188b --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/subagents-pattern.md @@ -0,0 +1,103 @@ +--- +name: subagents-pattern +description: When subagents earn their cost and how to compose them — swarm, pipeline, and guard patterns. +layer: pattern +cc_feature: subagents +source: https://docs.claude.com/en/docs/claude-code/sub-agents +concept: subagent-composition +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Subagents — Pattern + +## When to delegate + +Delegation earns its cost when at least one of these holds: + +- **Context isolation** — the subtask needs to read 50+ files or run + many greps, and the parent conversation does not need the raw + results. Summaries survive; raw output stays in the subagent. +- **Parallelism** — multiple independent subtasks can run at once, + compressing wall-clock time. +- **Specialization** — the subagent has a tailored system prompt that + changes its behavior meaningfully (e.g., adversarial reviewer). +- **Tool scoping** — the subtask should run with fewer tools than the + parent (principle of least privilege). + +If none of these apply, inline the work. A subagent call costs a full +model turn; do not pay it for routine reads. + +## Common patterns + +### Pattern A: Exploration swarm + +Parent launches 4-8 specialized subagents in parallel, each with a +narrow brief (architecture, dependencies, risks, tests, ...). Each +returns a summary. Parent synthesizes. + +Used by: `ultraplan-local` Phase 2 exploration. + +Cost shape: N × Sonnet call, wall-clock ≈ slowest subagent. + +### Pattern B: Adversarial review + +Parent writes an artifact (plan, design note). Launches a reviewer +subagent with a system prompt that demands problems, never praise. +Reviewer returns findings. Parent revises. + +Used by: `plan-critic`, `scope-guardian`, `architecture-critic`. + +Cost shape: 1 × Sonnet call per review pass. + +### Pattern C: Background orchestrator + +Parent kicks off a long-running orchestrator subagent with +`run_in_background: true`, then continues. Orchestrator runs its own +subagents, synthesizes, writes output to disk. Parent is notified on +completion. + +Used by: `planning-orchestrator`, `research-orchestrator`. + +Cost shape: 1 × Opus orchestrator + N × Sonnet workers. Overlaps with +other user work. + +### Pattern D: Guard subagent + +A hook delegates an "is this safe?" question to a subagent when the +answer needs judgment. The subagent returns a verdict; the hook +enforces it. + +Cost shape: 1 × Sonnet call per hook invocation. Use sparingly — +adds seconds of latency per tool call. + +## Pitfalls + +- **Delegate-understanding anti-pattern** — do not write "based on your + findings, fix the bug" to a subagent. The subagent is not inside your + head; it cannot see what you synthesized. Pass concrete context. +- **Prompt-on-top-of-prompt drift** — if the parent's prompt to a + subagent contradicts the subagent's own system prompt, the subagent + follows its system prompt. Do not try to re-style a reviewer into a + cheerleader by prompting harder. +- **Silent failure** — a subagent that returns "done" without evidence + may have done nothing. Trust but verify: check for the concrete + artifacts the subagent was asked to produce. +- **Orchestration explosion** — a three-level-deep subagent tree costs + exponentially. Flatten wherever the inner levels don't need their own + context isolation. +- **Token budget fights** — parent and all active subagents share the + harness's overall budget. Cap subagent output length ("report in + under 200 words") when the summary is what matters. + +## Composition with other features + +- Subagents + hooks: hooks fire during subagent tool calls too. A + subagent with only `Read` tools is already constrained; hooks add + defense in depth. +- Subagents + worktrees: an `isolation: "worktree"` subagent works in + an isolated copy of the repo, so its writes never clash with the + parent's writes. +- Subagents + background: run heavy exploration in background while the + user continues other work. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/subagents-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/subagents-reference.md new file mode 100644 index 0000000..379ac17 --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/subagents-reference.md @@ -0,0 +1,98 @@ +--- +name: subagents-reference +description: CC subagents — how the Task tool spawns isolated agent instances with scoped tools and context. +layer: reference +cc_feature: subagents +source: https://docs.claude.com/en/docs/claude-code/sub-agents +concept: task-tool-delegation +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Subagents — Reference + +Subagents are fresh Claude instances spawned via the Task tool. Each +receives a task prompt, a tool subset, and no memory of the parent +conversation except what the parent explicitly passes. They return a +single final message to the parent. + +## Anatomy + +A subagent has: + +- **A name** — either a built-in type (`general-purpose`, `Explore`, + `Plan`) or a plugin-defined type (`code-reviewer`, `test-runner`, + ...). +- **A system prompt** — defined by the agent type. The parent cannot + override it. +- **A tool set** — subset of the parent's tools, as declared in the + agent definition's frontmatter `tools:` field. +- **A task prompt** — what the parent asks it to do. Self-contained; + the subagent has no access to prior messages. +- **A model** — either explicit in the agent definition (`model: opus | + sonnet | haiku`) or inherited from the parent. + +## How to define a subagent + +A plugin agent is a markdown file in `agents/` with frontmatter: + +```yaml +--- +name: code-reviewer +description: +model: sonnet +tools: ["Read", "Grep", "Glob"] +--- + + +``` + +The `description` field is how Claude decides when to spawn this +subagent. Include concrete trigger examples. + +## How to invoke + +Parent calls the `Task` / `Agent` tool with: + +- `subagent_type` — the agent's name +- `description` — short label for logs +- `prompt` — the self-contained task + +Optional: + +- `run_in_background: true` — agent runs in the background; parent + is notified on completion. +- `isolation: "worktree"` — agent runs in a temporary git worktree + (isolated copy of the repo). + +## Return protocol + +- Foreground agent: parent blocks until the agent returns. Return value + is a single text message. +- Background agent: parent continues. On completion, the harness + injects a notification into the parent's next turn. + +## Isolation guarantees + +- No conversation history sharing. Each subagent starts cold. +- Separate context window. A subagent can read large files without + polluting the parent's context. +- Separate tool permissions. A subagent with only `Read` tools cannot + write files, even if the parent can. + +## Cost and latency + +- Every subagent call is a full model call with its own token budget. +- Model choice matters: Sonnet is ~5× cheaper than Opus; Haiku is + cheaper still but cannot be used (per project policy). +- Parallel subagents: the parent can launch multiple in one message; + the harness runs them concurrently. Total latency ≈ slowest agent. + +## Failure modes + +- Subagent hits context limit → partial or missing return. +- Subagent runs in background and the parent conversation ends → result + may be orphaned. +- Subagent's return message hallucinates file paths → caller must + verify. diff --git a/plugins/ultraplan-local/skills/cc-architect-catalog/worktrees-reference.md b/plugins/ultraplan-local/skills/cc-architect-catalog/worktrees-reference.md new file mode 100644 index 0000000..72cf16f --- /dev/null +++ b/plugins/ultraplan-local/skills/cc-architect-catalog/worktrees-reference.md @@ -0,0 +1,68 @@ +--- +name: worktrees-reference +description: CC git worktree integration — isolated repo copies per agent for parallel or destructive work. +layer: reference +cc_feature: worktrees +source: https://docs.claude.com/en/docs/claude-code/worktrees +concept: git-worktree-isolation +last_verified: 2026-04-18 +ngram_overlap_score: null +review_status: approved +--- + +# Worktrees — Reference + +Git worktrees let a repo check out multiple branches simultaneously in +separate directories. Claude Code integrates with worktrees to give +agents isolated filesystem scopes — one agent's edits cannot clash +with another's. + +## How it surfaces in CC + +- **`isolation: "worktree"` on a subagent call** — the harness creates + a temporary worktree for the subagent. The subagent runs with its + cwd set to the worktree. Changes stay there until merged or + discarded. +- **`/worktree` skill / command** — interactive tooling for creating, + listing, and merging worktrees during a session. +- **Auto-cleanup** — worktrees created by subagents are removed if the + subagent made no changes. Otherwise the path is returned in the + result for the caller to review. + +## Branch semantics + +- Each worktree checks out a named branch. Two worktrees cannot check + out the same branch (git's rule). +- Creating a worktree creates a branch if one does not exist. +- Deleting a worktree does not delete the branch; use `git branch -d` + separately if desired. + +## Use cases + +- **Parallel exploration** — three subagents trying three approaches, + each in its own worktree. The parent compares diffs. +- **Destructive experiments** — upgrade a dependency, run the full + test suite, measure breakage. Discard the worktree if results are + bad. +- **Long-running session without blocking main** — execute a refactor + in a worktree while continuing other work in the main checkout. + +## Pitfalls + +- **Shared state leaks** — node_modules, .env, build artifacts are + per-worktree but may be symlinked in ways that defeat isolation. + Verify. +- **Disk use** — each worktree is a full checkout of the tree. For + large repos, disk pressure adds up. +- **Branch proliferation** — agents that create worktrees without + cleanup leave orphan branches. Prune periodically. +- **Not a sandbox** — a worktree isolates files, not network or + processes. A subagent in a worktree can still call the outside + world. + +## Composition + +- Worktrees + background agents: a background agent in a worktree can + work on a long task while the user continues in the main checkout. +- Worktrees + subagents + hooks: hooks fire inside the worktree cwd, + so path-based hooks naturally scope to the isolated work.