一键导入
forge-discovery
Use when work needs codebase orientation, impact analysis, existing-pattern discovery, or risk scouting before planning or implementation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when work needs codebase orientation, impact analysis, existing-pattern discovery, or risk scouting before planning or implementation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when executing plans through specialized subagents with evidence-gated review loops
Use when work needs an explicit delivery contract, iterative repair, bounded autonomy, or resume-safe state
Use when a user asks to continue, resume, pick up prior loop work, or inspect previous loop state
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Use when implementation direction depends on unresolved product/design choices, multiple viable approaches, or owner approval on a design.
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
| name | forge:discovery |
| hidden | true |
| description | Use when work needs codebase orientation, impact analysis, existing-pattern discovery, or risk scouting before planning or implementation |
Discovery is the explicit "look before you build" gate. Its job is to find the smallest truthful context needed for planning, not to read the whole repository.
Core principle: No non-trivial plan without evidence about existing code, contracts, callers, and risk surface.
Use forge:discovery before forge:plan, forge:subagent, or direct edits when
ANY are true:
forge:loop starts and needs the Discovery step.Skip or downgrade when ALL are true:
Choose the cheapest depth that can falsify your assumptions.
| Depth | Use when | Required actions |
|---|---|---|
| D0 quick | Known file or docs-only change | Read target file plus nearby docs/callers |
| D1 scoped | Multi-file feature/fix | glob/grep or codesearch, read key files, list impact |
| D2 deep | Cross-module, API, DB, security, perf | Add dep-graph, schema-diff, dead-code, or specialist subagent |
Do not run D2 by default. Escalate only when D0/D1 cannot bound the risk.
When the surrounding task is route selection, contract establishment, or approval-before-execution, discovery enters approval-first mode.
In this mode:
Discovery MUST stop immediately once all three are true:
After the fuse criteria are met, additional reading is a violation, not extra rigor.
glob.grep.codesearch.dep-graph.schema-diff.dead-code.Explore or explore subagent with a focused query for evidence gathering only; discovery does not replace design convergence or owner approval.Guard or load the security skill before action.DBA or use DB-focused tools first.Discovery must produce this before planning or implementation:
Discovery depth: D0 | D1 | D2
Relevant files:
- <path> - why it matters
Existing behavior:
- <observed behavior or pattern, with file:line/tool evidence>
Impact surface:
- <callers/contracts/tests/docs likely affected>
Constraints:
- <rules, conventions, non-goals, compatibility notes>
Decision surface:
- <none | reversible assumption | owner decision required>
Risks:
- <risk level: low|medium|high> - <reason>
Recommended next skill: forge:brainstorm | forge:ask | forge:plan | forge:subagent | forge:tdd | forge:debug | normal flow
For loop work, cross-session handoff, or any task where another agent will plan or execute from discovery, produce two compact artifacts in the response or checkpoint details. Write files only when the caller explicitly asks for files or a plan requires durable handoff.
context.md# Code Context
## Files Retrieved
1. `path/to/file.ts` (lines 10-50) - why it matters
## Key Code
- Critical symbols, contracts, call chains, and small snippets only.
## Architecture / Data Flow
- How the relevant pieces connect.
## Constraints And Risks
- Existing conventions, compatibility notes, risk level, and open questions.
## Start Here
- The first file or command the next agent should inspect, with reason.
meta-prompt.md# Meta Prompt
Goal: concrete outcome the next agent should produce.
Context / Evidence:
- File:line facts, decisions, constraints, and source-backed observations.
Success Criteria:
- What must be true before the next agent can finish.
Hard Constraints:
- True invariants only; avoid restating preferences as requirements.
Suggested Approach:
- Concise direction without scripting every step.
Validation:
- Targeted checks to run, or the next-best check if validation is unavailable.
Stop / Escalation Rules:
- When to ask, when to block, and when enough evidence is enough.
Keep both artifacts high-signal. Do not paste exhaustive files, broad search dumps, or speculative implementation steps.
If evidence is insufficient, say exactly what is missing and either gather it or
block with forge:ask. If the real gap is a decision rather than evidence, stop discovering and route to forge:brainstorm or forge:ask. Do not convert guesses into plan requirements.
For approval-first tasks, do not chase repository-wide completeness. Discovery is successful when the route/proposal is supportable, not when the repo has been exhaustively mapped.
When called from forge:loop:
loop-start or iteration-N checkpoint details.forge:brainstorm / forge:ask before execution rather than substituting more search.| Mistake | Fix |
|---|---|
| Reading everything | Start D0/D1 and expand only from evidence |
| Planning from memory | Re-read current files; they may have changed |
| Treating grep hits as understanding | Read the owning file and caller context |
| Ignoring public contracts | Check callers, exports, schemas, and docs |
| Running heavy tools for tiny edits | Downgrade to D0 and preserve speed |
| Skipping risk labels | Mark low/medium/high so verify knows what to test |
| Turning route judgment into repo audit | Stop once route/contract truth is evidence-backed |
| Reading for completeness after the route is already clear | Trigger the evidence fuse and stop |
Discovery ends when the next implementation or planning step can name its relevant files, constraints, impact surface, and verification targets. If it cannot, discovery is not done.
If the blocker is no longer missing evidence but unresolved design or owner choice, discovery is done and the next step is forge:brainstorm or forge:ask.
For approval-first turns, discovery ends as soon as the route, contract, or proposal is evidence-backed enough to present truthfully. Do not continue reading for completeness once the evidence fuse is satisfied.