Prospector

From raddue/crucible · View interactive version

Prospector is an AI agent skill from the GitHub repository raddue/crucible. Explore a codebase for architectural friction and propose competing redesigns. Triggers on 'prospector', 'find improvements', 'architecture friction', 'what should I refactor', 'where are the structural problems', or any task requesting discovery of codebase improvement opportunities.

How to use this skill

Skill file

Prospector

<!-- CANONICAL: shared/dispatch-convention.md -->

All subagent dispatches use disk-mediated dispatch. See shared/dispatch-convention.md for the full protocol.

Explores a codebase organically, surfaces architectural friction, and proposes competing redesigns for the user to choose from.

Announce at start: "Running prospector on [codebase/directory name]."

Skill type: Rigid -- follow exactly, no shortcuts.

Purpose: Discover structural improvement opportunities in a codebase. Distinct from audit (which finds bugs in a specific subsystem) -- prospector finds what could be better across the entire codebase. Audit finds what's broken. Prospector finds what could be better.

Models: Orchestrator, organic explorer, and competing design agents request high; genealogists and structured analysis request standard. The Claude Code examples use current reference aliases for those profiles; other harnesses map supported profiles or omit unsupported model fields per shared/model-tier-policy.md. If no permitted high-profile model is available for exploration and design, or the harness can observe that the active orchestrator is not running one, warn: "Prospector requests high-profile reasoning for exploration and design phases. Results may be degraded." If active-model compliance cannot be observed, state that high-profile compliance is unverified before exploration and design. These warnings are advisory and must not terminate the pipeline.

Invocation

crucible:prospector                        # default — explore for all friction types
crucible:prospector --focus testability     # narrow: where is testing painful?
crucible:prospector --focus coupling        # narrow: where does change ripple?
crucible:prospector --focus complexity      # narrow: where are things over-engineered?
crucible:prospector --focus depth           # narrow: Ousterhout deep modules lens

Default mode uses the full friction example set. A --focus flag swaps in a targeted subset of guiding questions. The explorer is still organic — it can report friction outside its focus — but the focus tells it where to start looking.

Communication Requirement (Non-Negotiable)

Between every agent dispatch and every agent completion, output a status update to the user. This is NOT optional -- the user cannot see agent activity without your narration.

Every status update must include:

  1. Current phase -- Which phase you're in
  2. What just completed -- What the last agent reported
  3. What's being dispatched next -- What you're about to do and why
  4. Agent status -- During parallel phases (1.5+2, 3, 6): which agents have reported vs. still in flight, finding counts so far

After compaction: Re-read the scratch directory and current state before continuing. See Compaction Recovery below.

Examples of GOOD narration:

"Phase 1 complete. Explorer found 6 friction points (3 High, 2 Medium, 1 Low). Presenting for your review before committing genealogy + root cause dispatches."

"Phase 1.5+2: Genealogy 4/6 complete, Root cause 2/3 complete. 3 Incomplete Migrations, 1 Accretion so far. 4 agents still running."

"Phase 2.5: Convergence found 2 clusters (friction points #2+#5, #3+#7). Presenting draft for confirmation."

"Phase 6: All 3 competing designs complete. Presenting sequentially with comparison including 'Do Nothing' option."

Agent Budget

Total budget: ~24 agents. Worst case with 8 friction points (typically 3-4 High-severity):

Concurrency: Maximum 5 concurrent agents. Genealogy and root cause agents share this budget during their parallel execution window. The orchestrator dispatches them in round-robin fashion (e.g., 3 genealogy + 2 root cause, then backfill as each completes). Once both tracks complete, analysis agents use the full concurrency budget.

The explorer's output cap of 8 friction points enforces the overall budget. If the user requests exploration of a second candidate after completing the first, the budget resets for the new design cycle (Phases 5-7 only), reusing existing exploration and analysis results.

Scratch Directory

Canonical path: ~/.claude/projects/<project-hash>/memory/prospector/scratch/<run-id>/

The <run-id> is a timestamp generated at the start of Phase 1 (e.g., 2026-03-18T14-30-00). This same identifier is used for all scratch files and session logs throughout the run.

Files:

Stale cleanup: Delete scratch directories older than 24 hours at run start. Prospector runs include unbounded user interaction gaps, so do not delete directories that lack a decision.md file and are less than 24 hours old — they may be paused runs.

Session Tracking

Preferences Storage

Stored in ~/.claude/projects/<project-hash>/memory/prospector/preferences.md:

## Issue Tracker
- Tracker: [github|jira|linear|...]
- Project: [identifier]

First run: ask if user wants to file issues and which tracker. Persist for future runs.

Phase 0.5: Framework Detection

Framework detection is a deterministic orchestrator step that runs BEFORE explorer dispatch. The orchestrator reads dependency manifests directly — this is orchestrator-local work requiring 1-3 file reads, not an agent dispatch.

Phase 0.5 identifies which frameworks are declared (name + version). It does NOT determine which framework patterns are used, unused, or available — that requires code-level investigation and is handled by root cause agents in Phase 2 and analysis agents in Phase 3.

Dependency Manifests Checked

The orchestrator reads whichever of the following exist in the repository root (or known locations):

Output

A "Framework context" block (~5-10 lines) containing:

This block is a hint for downstream agents, not a definitive reference. Pattern-level investigation (which patterns are available and whether they are used or unused) is the responsibility of root cause agents (Phase 2) who have file access to the actual code.

This block is passed to the explorer agent, all root cause agents, all analysis agents, and all design agents.

Phase 1: Explore (Organic Discovery)

Pre-Exploration Context

Write Invocation State

At run start, write scratch/<run-id>/invocation.md containing:

The Organic Explorer

Dispatch: Agent tool (subagent_type: Explore, model: Opus) using ./explorer-prompt.md

The explorer receives:

Guiding friction examples (default mode):

Focus mode subsets:

| Focus | Guiding Examples |

|-------|-----------------|

| testability | Mock complexity, test-implementation coupling, untestable seams, pure-function extraction that misses real bugs |

| coupling | Shotgun surgery, ripple effects, shared mutable state, co-change patterns, circular dependencies |

| complexity | Over-abstraction, unnecessary indirection, configuration that exceeds the problem, premature generalization |

| depth | Shallow modules (Ousterhout), interface-to-implementation ratio, information hiding gaps, too many small files per concept |

The explorer outputs a structured list of friction points (capped at top 8, ranked by severity x frequency), each with:

Write-on-complete: The orchestrator writes the explorer's output to scratch/<run-id>/explorer-findings.md immediately upon agent completion. Do not hold results in context memory only — always persist to disk.

Explorer Context Budget

The explorer should target 50% of its context window for exploration, reserving the remainder for output generation. For large codebases:

Large Codebase Scoping

For codebases with 20+ top-level modules or directories:

  1. Perform a breadth-first pass first — read top-level directory structure, key entry points, existing architectural docs
  2. Produce a directory-level heat map indicating which areas look most promising for friction discovery
  3. Present the heat map to the user as part of the exploration review gate

If the explorer produces fewer than 3 friction points, report to the user and offer to re-run with: (a) a different starting area, (b) a --focus mode, or (c) user-specified directory scope.

User Gate: Exploration Review

USER GATE: Present the explorer's friction points to the user before committing genealogy and analysis agent dispatches (~16 agents). The user may:

Write scratch/<run-id>/exploration-approved.md when user confirms.

Phase 1.5: Friction Genealogy

After user approves exploration results, trace the causal origin of each approved friction point using git archaeology. Root cause analysis agents (Phase 2) run in parallel with genealogy — both investigate the same friction points independently.

Genealogist Agents

Dispatch: One agent per approved friction point, parallel (max 5), via Agent tool (subagent_type: general-purpose, model: Sonnet) using ./genealogist-prompt.md. Note: general-purpose (not Explore) because genealogists run git commands (git log, git blame, git show) which require Bash tool access.

Enhanced Output: Change Metrics

In addition to the standard genealogy data (origin classification, key commits, narrative), the genealogist agent's output now includes two structured numeric fields per friction point file:

The genealogist already runs git log and git blame on friction point files. These metrics are derived from the same data — no additional tool access is needed.

Git Metrics Aggregation

When a friction point spans multiple files, the genealogist reports per-file metrics for each file. The orchestrator aggregates these into the analysis agent's prompt as follows:

Each agent classifies the friction's origin:

| Origin Type | Description | Effort Implication |

|-------------|-------------|-------------------|

| Incomplete Migration | A refactoring or migration started but never finished | Lower — finish the existing migration path |

| Accretion | No single commit caused this; small additions over time | Higher — accumulated complexity must be disentangled |

| Forced Marriage | Two unrelated concerns coupled in a single commit | Medium — separation path is clear |

| Vestigial Structure | Old architecture replaced but scaffolding remains | Lower — fix may be deletion |

| Original Sin | Friction present in initial implementation | Higher — no prior art |

| Indeterminate | Git history insufficient (shallow clone, squash-only) | No adjustment |

Graceful degradation: Genealogy enriches when available but is never required. If git history is too shallow or all results are Indeterminate, downstream phases proceed without genealogy data.

Write-on-complete: The orchestrator writes each genealogist's output to scratch/<run-id>/genealogy-<n>.md immediately upon agent completion.

Phase 2: Root Cause Analysis

Root cause analysis runs in parallel with genealogy. Root cause looks at code structure ("why is this designed this way?"), genealogy traces git history ("how did it get this way?"). Both feed into Phase 2.5 convergence, then Phase 3.

Dispatch Criteria

Root cause agents are dispatched only for High-severity friction points. In a typical run with 8 friction points, 3-4 are High-severity.

Agent Spec

Dispatch: One agent per approved High-severity friction point, parallel with genealogy (shares max-5 concurrency budget with genealogists, dispatched in round-robin fashion), via Agent tool (subagent_type: general-purpose, model: Sonnet) using ./root-cause-prompt.md.

Each agent receives:

Each agent uses the competing causal hypotheses method: generates 2-3 plausible causal hypotheses, defines a falsification criterion for each, tests the criteria against the code, and reports which hypotheses survived.

Root Cause Types

| Type | Description |

|---|---|

| Missing or underused pattern | A known pattern exists in the ecosystem that would solve this, but the code uses a manual approach |

| Wrong abstraction | An abstraction exists but it models the wrong concept |

| Absent boundary | No module boundary exists where one should |

| Misaligned ownership | The boundary exists but the wrong module owns the concept |

| Other / Constraint-driven | Root cause is an external constraint, not an internal design flaw |

Scope and Termination

Write-on-complete: The orchestrator writes each root cause agent's output to scratch/<run-id>/root-cause-<n>.md immediately upon agent completion.

Phase 2.5: Root Cause Convergence

After all root cause agents and genealogy agents complete, the orchestrator checks whether multiple friction points share the same root cause. When they do, it collapses them into a single "friction cluster" with a unified remediation scope. This prevents producing interfering partial fixes for what is really a single architectural problem.

No agent dispatch — this is orchestrator-local work (Opus reads N root-cause files, groups them, writes one file).

How It Works

  1. Read all root-cause-<n>.md outputs
  2. Group by: same root cause type AND surviving hypothesis root cause statements describe the same architectural decision (semantic match, not string equality)
  3. Merge threshold: Two friction points merge only when they share the same root cause type AND their root cause statements describe the same underlying architectural decision or missing pattern. Overlapping symptoms or co-located files alone are not sufficient.
  4. Split criterion: Before merging, ask: "Would a single design change plausibly fix BOTH friction points?" If no, do not merge even if root cause type and statement match.

Merge Confidence

Medium/Low Finding Overlap Check

Before writing the draft, the orchestrator also checks whether any Medium/Low-severity finding (which did not receive a root cause agent) has symptom descriptions and file locations that overlap with a High-severity finding's root cause scope. Overlaps are flagged as Low-confidence potential merges for user confirmation.

Two-Step Convergence (Compaction-Safe)

  1. Draft step: Write proposed groupings to scratch/<run-id>/convergence-draft.md. Each proposed merge includes its confidence rating (High/Low) and the split criterion assessment. This is a checkpoint — if compaction occurs, the draft survives.
  2. Confirmation step: Present the draft to the user. High-confidence merges auto-approve; the user decides on Low-confidence merges (approve or split). The user may also split any auto-approved merge or force-merge missed connections. After confirmation, write the final scratch/<run-id>/convergence.md.

Downstream Impact

Phase 3: Structured Analysis (Enhanced)

The orchestrator reads explorer findings, genealogy results, root cause outputs, and convergence data from disk, then dispatches Structured Analysis Agents via Task tool (general-purpose, model: Sonnet) using ./analysis-prompt.md. One agent per friction point or convergence cluster, dispatched in parallel (max 5 concurrent).

Trajectory Context Loading

Before dispatching analysis agents, the orchestrator reads ~/.claude/projects/<project-hash>/memory/prospector/trajectory.jsonl (if it exists). For each friction point about to enter analysis, the orchestrator checks for fingerprint matches in the trajectory file (same friction type + >50% file path overlap).

If matches are found, the orchestrator computes the trajectory status:

The trajectory status and a one-line metric summary ("change freq: monthly→weekly→daily over 3 runs") are included in the analysis agent's input alongside the root cause summary and genealogy data. This costs ~2-3 lines of prompt budget per friction point.

Fingerprint matching degradation: If files are renamed or moved (common after acting on Prospector recommendations), path overlap drops below 50% and the match breaks. This is a known limitation — trajectory degrades gracefully to "NEW" for refactored code. The trajectory file retains the old entries for auditability. A future enhancement could add semantic similarity matching on friction descriptions, but for v2, structural fingerprinting is sufficient.

Track Only resurfacing: If a friction point was previously track-only but its trajectory is now ACCELERATING, the orchestrator flags it for the user at the exploration review gate: "Friction point [X] was Track Only in the last run but is now accelerating. Recommend upgrading to High severity for root cause analysis."

Each analysis agent receives:

Root Cause Summary Extraction

The orchestrator produces the root cause summary by extracting four fields verbatim from the root cause agent's output — no summarization, no paraphrasing:

  1. Root cause type (1 line) — copied verbatim from "Type:" field
  2. Root cause statement (1 line) — copied verbatim from "Root cause statement:" field
  3. Pattern-level fix (1-2 lines) — copied verbatim from "Pattern-level fix:" field
  4. Framework-native solution (1-2 lines) — copied verbatim from "Framework-native solution:" field

For convergence clusters, append: "Cluster scope: merged from friction points #X, #Y, #Z — addresses shared root cause as a unit."

For Medium/Low-severity findings without a dedicated root cause agent: use either a one-line note from a neighboring High-severity finding (if applicable) or "Root cause not analyzed -- severity below threshold."

Source Prioritization for Convergence Clusters

When an analysis agent processes a convergence cluster:

  1. Full source for the highest-severity constituent finding's files
  2. Interface-only excerpts (function signatures, class declarations, public API surfaces) for other constituent findings' files
  3. If the cluster still exceeds the 2000-line cap after prioritization, the orchestrator splits the cluster into sub-clusters that each fit. The orchestrator warns the user: "Cluster [X] exceeds context budget and was split into sub-clusters. This partially reduces the convergence benefit." The decision journal logs the split and rationale. Sub-cluster analysis results are re-merged in the Phase 4 candidate presentation.

Each analysis agent outputs:

The last three fields form the design brief consumed by Phase 6 competing design agents.

Write-on-complete: The orchestrator writes each analysis agent's output to scratch/<run-id>/analysis-<n>.md immediately upon agent completion. (Analysis agents are Task tool dispatches — they return text to the orchestrator, who persists it.)

The orchestrator reads all analysis results from disk and synthesizes into a ranked candidate list using the formula leverage_score x modification_friction_score (High=3, Medium=2, Low=1). Ties are broken by comprehension friction score. Effort is shown separately as a cost indicator, not included in the ranking formula. Candidates where inaction is defensible are demoted to a "Track Only" section. Writes to scratch/<run-id>/candidates.md.

USER GATE: Candidate Selection — Present candidates to the user. Do not proceed until user picks one:

### Prospector Candidates

#### Active Candidates (ranked by leverage x modification_friction)

1. **[Score: 9] [Effort: Medium] [Full analysis] Payment processing cluster**
   - Friction: Understanding payment flow requires reading 8 files across 3 directories
   - Root cause: Missing or underused pattern -- no aggregate module, each concern handled individually
   - Origin: Incomplete Migration (commit abc123)
   - Comprehension: High | Modification: High | Leverage: High
   - Framework check: None identified
   - Cost of inaction: Modified weekly, 4 bug-fix commits in 6 months. Not defensible.
   - Trajectory: STABLE (2 runs)

2. **[Score: 6] [Effort: Low] [Limited -- no root cause] Auth middleware duplication**
   - Friction: Auth checks duplicated across 4 route handlers
   - Root cause: Root cause not analyzed -- severity below threshold
   - Origin: Accretion (no single commit)
   - Comprehension: Medium | Modification: High | Leverage: Medium
   - Framework check: Express middleware pattern (framework hint only -- pattern usage not verified)
   - Cost of inaction: Modified weekly, 2 bug-fix commits in 6 months. Not defensible.
   - Trajectory: NEW

---

#### Track Only (inaction defensible -- low modification friction or low leverage)

3. **[Score: 3] [Effort: Low] [Limited -- no root cause] GameBootstrap god-class**
   - Friction: Hard to read (2,393 lines) but modification pattern is clear (~5 lines per change)
   - Root cause: Missing or underused pattern -- no self-registration, but modification cost is low
   - Comprehension: High | Modification: Low | Leverage: Low
   - Framework check: VContainer IInitializable would solve this (framework hint only -- pattern usage not verified)
   - Cost of inaction: Modified monthly, 0 bug-fix commits. Defensible -- rarely modified, clear patterns.
   - Trajectory: STABLE (4 runs)

Data Quality Indicators

Each candidate is tagged with:

Constraint-Driven Root Cause Warning

When a candidate's root cause type is "Other / Constraint-driven," the candidate presentation includes a warning: "Root cause is an external constraint -- designs address symptoms, not the underlying cause." The orchestrator does NOT auto-demote these.

Just-in-Time Root Cause for Limited Candidates

If the user selects a [Limited -- no root cause] candidate for design, the orchestrator dispatches a just-in-time root cause agent for that finding before proceeding to design agent dispatch. This single Sonnet dispatch is cheap compared to dispatching three Opus design agents without root cause data.

After the JIT root cause agent completes, the orchestrator compares its output against existing root-cause files and convergence clusters. If the JIT root cause matches an existing cluster's shared root cause, the orchestrator warns the user: "This finding appears to share a root cause with [cluster X]. Continue separately, merge into cluster X, or skip?" The user decides before design agents are dispatched.

User selects by number. Orchestrator proceeds to problem framing for that candidate.

Phase 5: Frame the Problem Space

Before spawning competing design agents, write a user-facing explanation:

Write to scratch/<run-id>/problem-frame.md.

USER GATE: Present the problem framing to the user and wait for confirmation before dispatching design agents. The framing directly determines the constraint selection in Phase 6 — dispatching 3 Opus agents with wrong inputs is expensive. User may adjust constraints, dependencies, or dependency category before proceeding.

Phase 6: Competing Designs (Contextual Constraints)

Constraint Selection

The orchestrator selects 3 design constraints from a deterministic mapping in REFERENCE.md. The mapping is keyed by friction type classification (from Phase 3 analysis). Each friction type has exactly 3 associated constraints — the orchestrator looks up the friction type and uses its constraints. This is a routing decision, not a creative one.

Friction-type-to-constraint mapping (canonical, in REFERENCE.md):

| Friction Type | Constraint 1 | Constraint 2 | Constraint 3 |

|--------------|--------------|--------------|--------------|

| Shallow modules | Minimize interface (1-3 entry points) | Optimize for most common caller | Hide maximum implementation detail |

| Coupling/shotgun surgery | Consolidate into single module | Introduce facade pattern | Extract shared abstraction with clean boundary |

| Leaky abstraction | Seal the abstraction (hide all internals) | Replace with simpler direct approach | Ports & adapters (injectable boundary) |

| Testability barrier | Boundary-test-friendly interface | Dependency-injectable design | Pure-function extraction with integration wrapper |

| Scattered domain | Aggregate into domain module | Event-driven decoupling | Layered with clear ownership per layer |

If a friction point doesn't match any defined type, the orchestrator falls back to a generic set: "Minimize interface," "Maximize flexibility," "Optimize for most common caller." The decision journal must log which constraint set was selected and why.

Dynamic Constraint Overrides

The constraint table above is the default. The following overrides apply when root cause analysis provides additional signal:

Root-Cause-Aware Framework Override

When the root cause type is "Missing or underused pattern" AND a framework-native solution was identified in Phase 3:

Root-Cause-Type-Derived Override

When the root cause type suggests a specific design direction:

These overrides apply to Slot 3. If a framework-native override already occupies Slot 1, the root-cause-type override replaces Slot 3 — both can coexist. Root cause types "Misaligned ownership" and "Other / Constraint-driven" do not trigger this override.

Standard Framework-Native Slot

When Phase 3 identified a framework-native solution BUT root cause type is NOT "Missing or underused pattern":

When no framework-native solution was identified: all 3 slots from friction-type mapping (unchanged).

The decision journal must log which constraint set was selected and which overrides applied.

Design Agent Dispatch

Spawn 3 agents in parallel via Agent tool (subagent_type: general-purpose, model: Opus) using ./design-competitor-prompt.md.

Each agent receives (subject to 2000-line hard cap):

Write-on-complete: The orchestrator writes each design agent's output to scratch/<run-id>/design-<n>.md immediately upon agent completion.

Each agent outputs:

  1. Interface signature — types, methods, params
  2. Usage example — how callers use the new interface
  3. What complexity it hides internally
  4. Dependency strategy — how deps are handled (mapped to the dependency category)
  5. Testing strategy — what tests look like at the new boundary
  6. Trade-offs — what you gain and what you give up
  7. Root cause coverage — Does this design address the root cause? Yes/Partially/No, with explanation

Design agents are instructed: "Your proposal must address the surviving root cause hypothesis, not just the symptom identified by the explorer. Review the falsified hypotheses to understand what the root cause is NOT."

Presentation

Present designs sequentially, then compare in prose. Give an opinionated recommendation: which design is strongest and why. If elements from different designs combine well, propose a hybrid. The user wants a strong read, not just a menu.

"Do Nothing" Comparison

After all designs are presented, include a mandatory comparison table with a "Do Nothing" column:

| Dimension | Design A | Design B | Design C | Do Nothing |
|---|---|---|---|---|
| Root cause addressed? | Yes | Partially | Yes | No |
| Effort | Medium | Low | High | None |
| Leverage | High | Medium | High | N/A |
| Risk | Medium | Low | High | None |
| Lines changed (est.) | ~200 | ~80 | ~500 | 0 |
| Cost of inaction | -- | -- | -- | [from analysis] |

The orchestrator still gives an opinionated recommendation, but "do nothing" is explicitly on the table.

Phase 7: User Picks a Design

User selects a design, accepts the recommendation, or requests a hybrid. Orchestrator records the decision to scratch/<run-id>/decision.md.

Phase 8: Output

Design Doc

Write a design doc to docs/plans/YYYY-MM-DD-prospector-<topic>-design.md where <topic> is a kebab-case slug derived from the selected candidate's name, truncated to 40 characters. If the file already exists, append a numeric suffix (-2, -3). The doc contains:

Trajectory Snapshot

At the end of every run — regardless of whether the user proceeds to build, files an issue, or keeps the design doc — the orchestrator writes a friction trajectory snapshot to persistent storage.

File: ~/.claude/projects/<project-hash>/memory/prospector/trajectory.jsonl

Each approved friction point (from the exploration review gate) becomes one JSONL line:

~~~json

{"timestamp": "2026-03-23T14:30:00", "fingerprint": {"files": ["src/GameBootstrap.cs", "src/Services/"], "friction_type": "Coupling / shotgun surgery", "root_cause_type": "Missing or underused pattern"}, "metrics": {"change_freq": "weekly", "bug_fix_count": 4, "modification_friction": "High", "leverage": "High"}, "disposition": "selected-for-design", "run_id": "2026-03-23T14-30-00"}

~~~

Fields:

Fingerprint matching across runs uses: same friction type AND overlapping file paths (>50% overlap). Root cause type is included for context but not required to match (root cause classification may evolve as the codebase changes).

The trajectory file is append-only. Each run appends N lines (one per approved finding). Reading the file is a single file read at the start of Phase 3.

User Choice

After saving the design doc, ask the user:

"Design doc saved. Would you like to:

(a) File this as an issue in your tracker

(b) Kick off build in refactor mode to implement it

(c) Just keep the design doc for now

(d) Explore another candidate from the list"

Option (a): File as an issue using whatever tools are available in the environment. Tracker-agnostic — no hardcoded assumption about GitHub, Jira, Linear, or anything else. If tracker preference isn't stored, ask the user. Persist preference.

Option (b): Invoke crucible:build in refactor mode. The user provides the prospector design doc as context for build's interactive design phase. Build runs its own Phase 1 normally (including blast radius analysis, impact manifest, contract tests).

Option (c): Done. Design doc is committed and available for future reference.

Option (d): Return to Phase 4 (candidate selection). Reuse existing exploration and analysis results from disk — no re-exploration needed. Budget resets for Phases 5-7 only (3 Opus design agents). New candidate's design doc saved alongside the first.

End-of-Run Cleanup

Delete scratch/<run-id>/ after all Phase 8 actions are complete (design doc saved, issue filed if requested, or build handoff initiated).

Cartographer Recording

After Phase 8, dispatch crucible:cartographer-skill (record mode) with the user-approved friction points from the exploration review gate. Record only friction point locations and classifications — not raw explorer observations or unconfirmed speculation.

Dependency Categories

Classification system for the target code's dependencies:

1. In-Process

Pure computation, in-memory state, no I/O. Always improvable — merge modules and test directly.

2. Local-Substitutable

Dependencies with local test stand-ins (e.g., SQLite for Postgres, in-memory filesystem). Improvable if the stand-in exists.

3. Remote but Owned (Ports & Adapters)

Your own services across a network boundary. Define a port at the module boundary; inject transport. Tests use an in-memory adapter.

4. True External (Mock)

Third-party services you don't control (Stripe, Twilio, etc.). Mock at the boundary via injected port.

Compaction Recovery

After context compaction:

  1. Read scratch/<run-id>/invocation.md first — recover focus mode and directory scope before any other state
  2. Read remaining scratch/<run-id>/ files to determine current state
  3. explorer-findings.md exists → Phase 1 exploration complete
  4. exploration-approved.md exists → user gate passed. If missing but explorer-findings.md exists, re-present friction points for confirmation.
  5. Check completion state of BOTH parallel tracks before advancing:

a. Read explorer-findings.md to determine expected count N (total) and H (High-severity count)

b. Count existing genealogy-<n>.md files. If fewer than N, dispatch remaining genealogy agents

c. Count existing root-cause-<n>.md files. If fewer than H, dispatch remaining root cause agents (High-severity findings only)

d. Wait for ALL dispatched agents from BOTH tracks to complete before proceeding

  1. convergence-draft.md exists but convergence.md does not → re-read draft and present to user for confirmation (skip grouping analysis)
  2. convergence.md exists → Phase 2.5 complete. If neither convergence file exists but all root-cause and genealogy files are complete, re-run convergence from scratch (orchestrator-local, cheap).
  3. candidates.md exists → Phase 3 complete, re-present to user if no selection recorded
  4. problem-frame.md exists → Phase 5 complete
  5. design-*.md files → count competing designs, dispatch remaining if incomplete
  6. decision.md exists → Phase 7 complete, proceed to output
  7. Output status update before continuing

Guardrails

The explorer must NOT:

Analysis agents must NOT:

Design agents must NOT:

The orchestrator must NOT:

Red Flags

Integration

Subagent Dispatch Summary

| Agent | Model | Dispatch | Prompt Template |

|-------|-------|----------|-----------------|

| Organic Explorer | Opus | Agent tool (Explore) | ./explorer-prompt.md |

| Genealogist (per friction point) | Sonnet | Agent tool (general-purpose) | ./genealogist-prompt.md |

| Root Cause (per High-severity friction point) | Sonnet | Agent tool (general-purpose) | ./root-cause-prompt.md |

| Structured Analysis (per friction point or cluster) | Sonnet | Task tool (general-purpose) | ./analysis-prompt.md |

| Competing Design Agents (x3) | Opus | Agent tool (general-purpose) | ./design-competitor-prompt.md |

Prompt Templates

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.