gitnexus-plan — implementation-ready engineering plans
Produce an implementation-ready plan for an engineering task. GitNexus is the
navigation layer (where to look), statement-level PDG is the constraint layer
(what gates and feeds the behavior), and your native targeted source reads are
the verification layer (what is actually true right now). The output is a plan
document plus a compact, machine-readable implementation context pack
that a follow-up implementation agent (gitnexus-work, or any executor) can
consume without repeating the investigation.
/gitnexus-plan <task description>
/gitnexus-plan impact_depth:3 depth:deep <task description> # knob overrides, see Configuration
This skill plans. It never implements. Do not modify production code,
tests, or configuration while running it. The only repository file it writes
is the plan document (a working ledger kept outside the repo is fine). The
only other permitted state change is an index refresh via
analyze --index-only, which writes only the .gitnexus index store. It
must not build analyzer dist/ output and must not mutate source, tests,
configuration, or evaluation data. Stale analyzer provenance is disclosed as
a source-weighted limitation, never repaired by a planning run.
Hard rules
- Ledger first. Before every GitNexus call and every repo file read, check
the context ledger. Never repeat a query or reread an unchanged range that
already answered the same question (allowed repeats are defined in
references/context-ledger.md; this skill's own reference files are exempt
from ledger bookkeeping).
- Every graph query answers a named planning question. Record the question
and the conclusion in the ledger. No exploratory dredging.
- Source beats graph. The graph navigates; current source is authoritative.
Verify before asserting (see Phase 4). Comments are the weakest evidence —
never stronger than executable code.
- No fabrication. Never invent symbols, filenames, test names, tool
results, or PDG edges. Unknowns go to Assumptions and Open Questions.
- No scope creep. Adjacent refactors the task didn't ask for go to plan
§12 as explicitly-deferred follow-ups, not into Proposed Changes.
- Pin working-tree evidence, not only HEAD. Every plan form carries the
versioned global dirty digest and sorted cited-path manifest defined in
references/context-ledger.md. Generate it only with the portable helper
and byte contract in scripts/evidence-provenance.mjs and
references/evidence-provenance.md; never reimplement the digest.
- Write the plan only through the helper. The generated-plan path is a
normalized repo-relative
docs/plans/YYYY-MM-DD-gitnexus-plan-<3-5-word-slug>.md path. Compose the
complete UTF-8 document in memory or in a scratchpad outside the target
repo, then pass it on stdin to the helper's write-plan command. Never
write the destination directly or fall back to an external output path when
the safe writer fails.
- Read an existing plan only through the helper. Deepen must invoke
scripts/evidence-provenance.mjs read-plan, parse the exact decoded
plan_bytes_base64 from its descriptor-anchored receipt, and retain that
receipt's canonical generated_plan_path and plan_digest as one binding.
Never parse a direct lexical-path read or apply one plan's digest to another
path.
- Stop when you have enough. Sufficient evidence ends exploration; plans
do not improve monotonically with tokens spent.
Phase 0 — Parse and classify
Read references/context-ledger.md and open the ledger with the task:
original request, interpreted goal, acceptance criteria. Classify the task:
| Category |
Posture (depth · plan form · tool-call budget · freshness) |
| Bug fix (local) |
Narrow, 1–2 primary symbols, impact_depth 1 · compact · ~15 · accept |
| Feature |
Default knobs · compact · ~30 · accept |
| Refactor / shared API change |
Impact mandatory, impact_depth 3 · full · ~45 · strict |
| Performance |
Default + performance PDG mode (references/pdg-slice.md) · full · ~45 · strict |
| Security |
Default + security PDG mode + explain taint findings · full · ~45 · strict |
| Dependency upgrade / migration |
Impact + compatibility focus; PDG rarely needed · compact · ~20 · accept |
| Concurrency / transactional |
Control-flow + state-mutation PDG focus · full · ~45 · strict |
| Test improvement / docs |
Narrowest: usually no impact or PDG pass · compact · ~10 · accept |
| Architecture change / spike |
Widest: clusters + processes first · full · no cap · strict |
The category posture overrides the Configuration baseline; explicit key:value
invocation knobs override both. A task matching several rows combines them:
take the widest depth, union the focus areas.
Seeded evidence. When a completed investigation already supplies
verified findings — a finished review, a triage document with path:line
anchors and named failing scenarios — open the ledger FROM it: cite the
source document as the opening ledger entries and plan directly against
them instead of re-running the graph ladder over ground it already covers.
Re-deriving what the evidence proves is budget spent against the
turn-economy rule. Phase 4 still source-verifies whatever Proposed Changes
will cite, at the pinned commit — seeding replaces exploration, never
verification.
Depth is the user's decision, asked once, up front. In an interactive
session, when the invocation carries no explicit depth signal (no depth:,
form:, or freshness: knob, and not Deepen mode), ask one blocking
question before Phase 1 — how deep should this plan go?
- Quick —
depth:narrow form:compact freshness:accept. Fastest useful
plan: 1–2 primary symbols, minimal graph work, core sections only.
- Standard — the category posture above, unchanged. Recommend this
unless the classification argues otherwise.
- Deep —
depth:deep form:full freshness:strict. All 13 sections,
impact_depth 3, clusters/processes read, PDG slices for the central
functions.
The answer sets the knobs exactly as if they had been typed in the
invocation; explicit knobs win and skip the question. Headless runs never
ask — the category posture applies unchanged. Asking up front replaces
offering to deepen a finished plan afterwards: Deepen mode (below) remains
the mechanism for strengthening an existing plan document — a later session,
review findings, an executor route-back — not a default follow-up question.
Turn economy is a deliverable. The plan is judged on decision quality per
token, not thoroughness theater (measured: a 63-turn plan for a two-line
change — the GitNexus repo's eval/workflow_bench/). Stay within the category's tool-call
budget; when the budget runs out with questions still open, record them in
§12 instead of digging further — the executor re-verifies cheaply anyway.
Phase 1 — Anchor and freshness
- Resolve the target repo:
list_repos if in doubt, else the indexed repo
covering the working directory. Pass repo explicitly on every call when
more than one repo is indexed.
- Record the repo's current HEAD commit in the ledger — every line-number
citation in the plan is pinned to it.
- Resolve and record the analyzer runner (used by every
analyze
command in this skill): node .gitnexus/run.cjs analyze … when the
project has a runner (a previous analyze dropped it next to the index),
else gitnexus analyze … (installed CLI — npm install -g gitnexus),
else npx gitnexus analyze …. Record its path/version and any available
source/build identity; do not manufacture provenance from timestamps.
- Read
gitnexus://repo/{name}/context — codebase overview + staleness check.
Freshness gate. Plans built on a stale graph make stale blast-radius
claims — but a re-index is the largest fixed cost a planning session
carries, so the gate is category-priced:
- Compact-plan categories default to
freshness: accept: plan on the
current graph with source verification weighted higher — their plans
cite little graph evidence. Escalate to a refresh mid-plan only when a
graph claim becomes load-bearing (e.g. Proposed Changes rest on a d=1
dependent list), and only then.
- Full-plan categories default to
freshness: strict, and under it:
- Analyzer provenance check — before any refresh. Compare the resolved
runner identity with the index metadata and, in an analyzer-source
checkout, with current analyzer source. If identity is stale or unknown,
do not build output and do not make that graph load-bearing. Record a
stale analyzer provenance — source-weighted limitation in
index_refresh, the plan header, and §12; rely on targeted source reads
or hand execution to gitnexus-work, which owns the build-current gate.
- Stale index → run
analyze --index-only via the resolved runner
(append --pdg when the task category will reach Phase 3) and re-read
the context resource only when runner provenance is known-current.
Refresh budget, stated once here: at most one --index-only refresh in
Phase 1 plus at most one later --pdg upgrade in Phase 3 (only when
Phase 1's refresh lacked --pdg) per planning session — a Deepen run is
its own session. Record each command, runner identity, and outcome in the
ledger's index_refresh.
- Refresh failed or impractical (no write access to the index, prohibitive
repo size), or
freshness: accept was passed → proceed on the stale
graph, weight source verification higher, and state the staleness and
the skipped refresh in the plan header and Assumptions.
- Resources unreadable but tools working → proceed on tools alone, treat
freshness as unknown (weight source higher), and note it in the plan.
- GitNexus unavailable entirely → switch to Fallback mode (below).
- For architecture-scale tasks only, also read
gitnexus://repo/{name}/clusters and .../processes.
Phase 2 — Graph navigation ladder
Use the narrowest operation that answers the current ledger question, in this
order. Budgets: at most max_primary_symbols (5) primary symbols and
max_related_symbols (20) related symbols active in the ledger.
query {search_query, task_context} — locate concepts, execution flows,
modules, and related tests for the task.
context {name} — 360° view of each candidate primary symbol: callers,
callees, categorized refs, processes. Promote to primary or discard. An
ambiguous result (ranked candidates) is answered by one retry narrowed
with kind / file_path / uid — that retry is an allowed repeat.
impact {target, direction} — upstream/downstream blast radius for shared
or high-connectivity symbols (maxDepth = impact_depth; summaryOnly: true first for hub symbols, then drill in — an allowed repeat). Record the
d=1 items — the direct (depth-1) dependents — the plan must account
for every one of them.
trace {from, to} — when the task hinges on how A reaches B, one call
instead of chained context hops.
- Statement-level PDG — Phase 3, for the functions the change centers on.
cypher — last resort, only for a precise graph question the tools above
cannot express. Read gitnexus://repo/{name}/schema first; anchor and
LIMIT every query.
detect_changes {scope} — only when planning against existing uncommitted
or branch work.
Do not run every tool by default. A local test fix may finish the ladder at
step 2.
Phase 3 — Statement-level PDG slice
For the 1–3 functions most central to the change, build a bounded PDG
context slice. Read references/pdg-slice.md and follow it — it owns the
tool calls, inclusion criteria, depth bounds, slice schema, the security and
performance modes, and the no-PDG-layer fallback.
Phase 4 — Targeted source verification
GitNexus said where to look; now confirm what is there. Using ordinary file
reads (exact line ranges, not whole files unless genuinely required):
- Read every source range the plan will cite: signatures, branch conditions,
state mutations, error paths, nearby comments that change behavior. Compact
plans cite less — verify what they cite, don't expand the citation set to
have more to verify.
- Read the tests GitNexus associated with the primary symbols; never claim a
test exists without having located it.
- Verify the build/test commands the plan will name actually exist
(package.json scripts / CI workflows), and prefer the script form that
carries its prerequisites (pre-hooks) over invoking underlying binaries
directly.
- Check repo conventions that constrain the change (AGENTS.md, GUARDRAILS.md,
lint/build config) — only the parts the change touches.
- Mark each ledger symbol
source_verified: true as you go. A symbol that
is named in Proposed Changes must be source-verified.
- On graph/source disagreement: trust source, record the discrepancy in the
ledger and the plan, recommend re-indexing. Never present stale graph data
as fact.
- Immediately before composition, recompute the versioned
evidence_provenance snapshot by invoking
scripts/evidence-provenance.mjs exactly as specified in
references/evidence-provenance.md: the
canonical global dirty digest over all dirty paths and the sorted manifest
of every cited path, including object kind and
HEAD/index/worktree/untracked layer digests. Re-read any citation that
changed during planning. Exclude only the generated plan path.
Evidence hierarchy, strongest first: current source and config → current tests
and executable behavior → compiler/build/lint output → GitNexus graph and PDG
→ documentation and comments.
Phase 5 — Compose the plan
- Read
references/plan-template.md and fill the category's form — compact
(core sections, ≤80 lines excluding the pack) or full (all 13 sections) —
from the ledger, tagging claims with the template's four classes —
[verified], [graph], [inferred], [assumed] — and routing open
questions to §12.
- Build the implementation context pack per
references/context-pack.md
(this is section 11 of the plan), including mandatory
evidence_provenance in compact and full forms.
- Set
generated_plan_path to
docs/plans/YYYY-MM-DD-gitnexus-plan-<slug>.md under the root of the repo
being planned (the Phase 1 target repo, not necessarily the cwd); use a
3–5-word kebab-case slug and repo-relative paths inside the document.
Compose the complete document without creating that destination, then
pipe its exact UTF-8 bytes to scripts/evidence-provenance.mjs write-plan
as specified in references/evidence-provenance.md. The helper safely
creates missing parent directories. Initial planning must not pass
--replace. A safe-write failure blocks plan publication: report it and
do not write directly, choose an external destination, or weaken the
repo-relative provenance contract. The snapshot and writer commands apply
the same strict generated-plan filename/date validator; do not substitute a
source, .git, or arbitrary docs/plans/ path in either invocation.
- Present in chat: objective, proposed-changes summary, implementation
sequence, top risks, open questions, and the plan file path. Do not paste
the whole document into chat.
Deepen mode
/gitnexus-plan deepen <plan-path> strengthens an existing plan in place
instead of creating a new one:
- Resolve the target repository and normalized repo-relative plan candidate,
then load it with
scripts/evidence-provenance.mjs read-plan --repo <root> --generated-plan <candidate> exactly as specified in
references/evidence-provenance.md. Reject a missing, external, escaping,
symlinked, or differently scoped path. Decode and parse only the receipt's
exact plan_bytes_base64; retain its canonical generated_plan_path and
plan_digest unchanged for the entire Deepen session.
- Re-run Phase 1 in full — analyzer provenance check and freshness gate (a
Deepen run is its own session, with its own refresh budget).
- Re-anchor before re-pinning. Recompute the plan's global dirty digest
and cited-path manifest as well as comparing its old HEAD pin with current
HEAD. Changed, renamed, deleted, mixed, or newly absent cited paths get
their ranges re-read — or the claim downgraded — before the pin and
provenance snapshot move. Moving only the commit pin silently launders
dirty or stale claims as verified.
- Escalate to
depth: deep (impact_depth 3, clusters/processes read)
unless the invocation overrides knobs explicitly.
- Seed the ledger from the plan's §11 pack, then re-verify: every
[graph]/[inferred] claim gets a targeted pass toward [verified];
every [assumed] claim is resolved or kept with its reason; direct
(d=1) dependent accounting is re-checked against the refreshed graph;
PDG slices are built or expanded for the central functions when the
layer is present.
- Reconcile execution state. If
gitnexus-work already landed commits
for this plan (a mid-execution route-back), mark the §7 steps present at
HEAD as completed and re-sequence the remainder — the rewritten plan must
be executable from the top without redoing landed steps.
- Strengthen whatever the deeper pass showed thin — test scenarios, risks,
Definition of Done — and carry claim-tag upgrades through the prose.
- Rewrite the same canonical file through
scripts/evidence-provenance.mjs write-plan --replace --expected-plan-path <retained-read-plan-path> --expected-plan-digest <retained-read-plan-digest>: same 13 sections,
context pack kept in sync, evidence header updated. --replace is reserved
for Deepen mode, and both expected values must come from the same read-plan
receipt; any digest/path mismatch blocks publication. Retain the successful receipt's
prior_plan_backup_git_path; it names the verified Git-admin backup of the
displaced plan. Summarize the delta in chat: claims upgraded, claims that
failed re-verification, sections changed, and that backup path.
Configuration
Baseline defaults — the Phase 0 category posture overrides them, and inline
key:value tokens before the task text override both (the repo has no
skill-config file mechanism; invocation args are the mechanism):
| Knob |
Default |
Meaning |
depth |
by category |
narrow = impact_depth 1, PDG only if one function is clearly central; default = this table; deep = impact_depth 3 + clusters/processes read |
form |
by category |
compact (core sections + mini-pack, ≤80 lines excl. pack — see references/plan-template.md) or full (all 13 sections) |
impact_depth |
2 |
maxDepth for impact |
pdg_data_depth |
2 |
Data-dependence hops in the PDG slice |
pdg_control_depth |
2 |
Control-dependence hops in the PDG slice |
max_primary_symbols |
5 |
Ledger budget (active symbols; discards don't count) |
max_related_symbols |
20 |
Ledger budget (active symbols; discards don't count) |
max_snippet_lines |
30 |
Longest source excerpt quoted in the plan |
freshness |
by category |
strict (full-plan categories) = refresh a stale index (and a missing PDG layer) with analyze --index-only [--pdg] before relying on the graph; accept (compact categories) = plan on the current graph, source-weighted and labelled, refreshing only if a graph claim becomes load-bearing |
Fallback mode (GitNexus or PDG unavailable)
- Say so, first thing, in chat and in the plan.
- Use targeted repo exploration (grep/glob/reads) to approximate callers,
dependencies, execution flow, state changes, and related tests.
- Label every such finding source-derived in the plan — never present it
as graph-derived, and never fabricate statement-level edges.
- Recommend
analyze --index-only (add --pdg for the PDG layers) via
the resolved runner — node .gitnexus/run.cjs, installed gitnexus, or
npx gitnexus — when it would materially raise confidence.
Skill feedback
If this run exposed friction in the instructions, include concise feedback in
the final response. Feedback is chat-only: do not append evaluation learnings,
edit benchmark data, or modify this skill during a live planning task.
1---2name: gitnexus-plan3description: Use when you need a deep, implementation-ready engineering plan for a code change — built from GitNexus graph intelligence, statement-level PDG analysis, and targeted source verification, compact enough that an implementation agent can start without re-investigating. Also strengthens existing plans via Deepen mode. Examples: "/gitnexus-plan Add retry support to the ingestion pipeline", "/gitnexus-plan deepen docs/plans/<plan>.md", "plan this change using the knowledge graph".4---5
6# gitnexus-plan — implementation-ready engineering plans
7
8Produce an implementation-ready plan for an engineering task. GitNexus is the
9navigation layer (where to look), statement-level PDG is the constraint layer
10(what gates and feeds the behavior), and your native targeted source reads are
11the verification layer (what is actually true right now). The output is a plan
12document plus a compact, machine-readable **implementation context pack**
13that a follow-up implementation agent (`gitnexus-work`, or any executor) can
14consume without repeating the investigation.
15
16```
17/gitnexus-plan <task description>
18/gitnexus-plan impact_depth:3 depth:deep <task description> # knob overrides, see Configuration
19```
20
21**This skill plans. It never implements.** Do not modify production code,
22tests, or configuration while running it. The only repository file it writes
23is the plan document (a working ledger kept outside the repo is fine). The
24only other permitted state change is an index refresh via
25`analyze --index-only`, which writes only the `.gitnexus` index store. It
26must not build analyzer `dist/` output and must not mutate source, tests,
27configuration, or evaluation data. Stale analyzer provenance is disclosed as
28a source-weighted limitation, never repaired by a planning run.
29
30## Hard rules
31
32- **Ledger first.** Before every GitNexus call and every repo file read, check
33 the context ledger. Never repeat a query or reread an unchanged range that
34 already answered the same question (allowed repeats are defined in
35 `references/context-ledger.md`; this skill's own reference files are exempt
36 from ledger bookkeeping).
37- **Every graph query answers a named planning question.** Record the question
38 and the conclusion in the ledger. No exploratory dredging.
39- **Source beats graph.** The graph navigates; current source is authoritative.
40 Verify before asserting (see Phase 4). Comments are the weakest evidence —
41 never stronger than executable code.
42- **No fabrication.** Never invent symbols, filenames, test names, tool
43 results, or PDG edges. Unknowns go to _Assumptions and Open Questions_.
44- **No scope creep.** Adjacent refactors the task didn't ask for go to plan
45 §12 as explicitly-deferred follow-ups, not into Proposed Changes.
46- **Pin working-tree evidence, not only HEAD.** Every plan form carries the
47 versioned global dirty digest and sorted cited-path manifest defined in
48 `references/context-ledger.md`. Generate it only with the portable helper
49 and byte contract in `scripts/evidence-provenance.mjs` and
50 `references/evidence-provenance.md`; never reimplement the digest.
51- **Write the plan only through the helper.** The generated-plan path is a
52 normalized repo-relative
53 `docs/plans/YYYY-MM-DD-gitnexus-plan-<3-5-word-slug>.md` path. Compose the
54 complete UTF-8 document in memory or in a scratchpad outside the target
55 repo, then pass it on stdin to the helper's `write-plan` command. Never
56 write the destination directly or fall back to an external output path when
57 the safe writer fails.
58- **Read an existing plan only through the helper.** Deepen must invoke
59 `scripts/evidence-provenance.mjs read-plan`, parse the exact decoded
60 `plan_bytes_base64` from its descriptor-anchored receipt, and retain that
61 receipt's canonical `generated_plan_path` and `plan_digest` as one binding.
62 Never parse a direct lexical-path read or apply one plan's digest to another
63 path.
64- **Stop when you have enough.** Sufficient evidence ends exploration; plans
65 do not improve monotonically with tokens spent.
66
67## Phase 0 — Parse and classify
68
69Read `references/context-ledger.md` and open the ledger with the task:
70original request, interpreted goal, acceptance criteria. Classify the task:
71
72| Category | Posture (depth · plan form · tool-call budget · freshness) |
73| ------------------------------ | -------------------------------------------------------------------------------- |
74| Bug fix (local) | Narrow, 1–2 primary symbols, `impact_depth` 1 · compact · ~15 · accept |
75| Feature | Default knobs · compact · ~30 · accept |
76| Refactor / shared API change | Impact mandatory, `impact_depth` 3 · full · ~45 · strict |
77| Performance | Default + performance PDG mode (`references/pdg-slice.md`) · full · ~45 · strict |
78| Security | Default + security PDG mode + `explain` taint findings · full · ~45 · strict |
79| Dependency upgrade / migration | Impact + compatibility focus; PDG rarely needed · compact · ~20 · accept |
80| Concurrency / transactional | Control-flow + state-mutation PDG focus · full · ~45 · strict |
81| Test improvement / docs | Narrowest: usually no impact or PDG pass · compact · ~10 · accept |
82| Architecture change / spike | Widest: clusters + processes first · full · no cap · strict |
83
84The category posture overrides the Configuration baseline; explicit `key:value`
85invocation knobs override both. A task matching several rows combines them:
86take the widest depth, union the focus areas.
87
88**Seeded evidence.** When a completed investigation already supplies
89verified findings — a finished review, a triage document with `path:line`
90anchors and named failing scenarios — open the ledger FROM it: cite the
91source document as the opening ledger entries and plan directly against
92them instead of re-running the graph ladder over ground it already covers.
93Re-deriving what the evidence proves is budget spent against the
94turn-economy rule. Phase 4 still source-verifies whatever Proposed Changes
95will cite, at the pinned commit — seeding replaces exploration, never
96verification.
97
98**Depth is the user's decision, asked once, up front.** In an interactive
99session, when the invocation carries no explicit depth signal (no `depth:`,
100`form:`, or `freshness:` knob, and not Deepen mode), ask one blocking
101question before Phase 1 — how deep should this plan go?
102
1031. **Quick** — `depth:narrow form:compact freshness:accept`. Fastest useful
104 plan: 1–2 primary symbols, minimal graph work, core sections only.
1052. **Standard** — the category posture above, unchanged. Recommend this
106 unless the classification argues otherwise.
1073. **Deep** — `depth:deep form:full freshness:strict`. All 13 sections,
108 `impact_depth` 3, clusters/processes read, PDG slices for the central
109 functions.
110
111The answer sets the knobs exactly as if they had been typed in the
112invocation; explicit knobs win and skip the question. Headless runs never
113ask — the category posture applies unchanged. Asking up front replaces
114offering to deepen a finished plan afterwards: Deepen mode (below) remains
115the mechanism for strengthening an existing plan document — a later session,
116review findings, an executor route-back — not a default follow-up question.
117
118**Turn economy is a deliverable.** The plan is judged on decision quality per
119token, not thoroughness theater (measured: a 63-turn plan for a two-line
120change — the GitNexus repo's `eval/workflow_bench/`). Stay within the category's tool-call
121budget; when the budget runs out with questions still open, record them in
122§12 instead of digging further — the executor re-verifies cheaply anyway.
123
124## Phase 1 — Anchor and freshness
125
1261. Resolve the target repo: `list_repos` if in doubt, else the indexed repo
127 covering the working directory. Pass `repo` explicitly on every call when
128 more than one repo is indexed.
1292. Record the repo's current HEAD commit in the ledger — every line-number
130 citation in the plan is pinned to it.
1313. **Resolve and record the analyzer runner** (used by every `analyze`
132 command in this skill): `node .gitnexus/run.cjs analyze …` when the
133 project has a runner (a previous analyze dropped it next to the index),
134 else `gitnexus analyze …` (installed CLI — `npm install -g gitnexus`),
135 else `npx gitnexus analyze …`. Record its path/version and any available
136 source/build identity; do not manufacture provenance from timestamps.
1374. Read `gitnexus://repo/{name}/context` — codebase overview + staleness check.
138 **Freshness gate.** Plans built on a stale graph make stale blast-radius
139 claims — but a re-index is the largest fixed cost a planning session
140 carries, so the gate is category-priced:
141 - Compact-plan categories default to `freshness: accept`: plan on the
142 current graph with source verification weighted higher — their plans
143 cite little graph evidence. Escalate to a refresh mid-plan only when a
144 graph claim becomes load-bearing (e.g. Proposed Changes rest on a d=1
145 dependent list), and only then.
146 - Full-plan categories default to `freshness: strict`, and under it:
147 - **Analyzer provenance check — before any refresh.** Compare the resolved
148 runner identity with the index metadata and, in an analyzer-source
149 checkout, with current analyzer source. If identity is stale or unknown,
150 do not build output and do not make that graph load-bearing. Record a
151 **stale analyzer provenance — source-weighted limitation** in
152 `index_refresh`, the plan header, and §12; rely on targeted source reads
153 or hand execution to `gitnexus-work`, which owns the build-current gate.
154 - Stale index → run `analyze --index-only` via the resolved runner
155 (append `--pdg` when the task category will reach Phase 3) and re-read
156 the context resource **only when runner provenance is known-current**.
157 Refresh budget, stated once here: at most one `--index-only` refresh in
158 Phase 1 **plus** at most one later `--pdg` upgrade in Phase 3 (only when
159 Phase 1's refresh lacked `--pdg`) per planning session — a Deepen run is
160 its own session. Record each command, runner identity, and outcome in the
161 ledger's `index_refresh`.
162 - Refresh failed or impractical (no write access to the index, prohibitive
163 repo size), or `freshness: accept` was passed → proceed on the stale
164 graph, weight source verification higher, and state the staleness and
165 the skipped refresh in the plan header and Assumptions.
166 - Resources unreadable but tools working → proceed on tools alone, treat
167 freshness as unknown (weight source higher), and note it in the plan.
168 - GitNexus unavailable entirely → switch to **Fallback mode** (below).
1695. For architecture-scale tasks only, also read
170 `gitnexus://repo/{name}/clusters` and `.../processes`.
171
172## Phase 2 — Graph navigation ladder
173
174Use the narrowest operation that answers the current ledger question, in this
175order. Budgets: at most `max_primary_symbols` (5) primary symbols and
176`max_related_symbols` (20) related symbols active in the ledger.
177
1781. `query {search_query, task_context}` — locate concepts, execution flows,
179 modules, and related tests for the task.
1802. `context {name}` — 360° view of each candidate primary symbol: callers,
181 callees, categorized refs, processes. Promote to primary or discard. An
182 `ambiguous` result (ranked candidates) is answered by one retry narrowed
183 with `kind` / `file_path` / uid — that retry is an allowed repeat.
1843. `impact {target, direction}` — upstream/downstream blast radius for shared
185 or high-connectivity symbols (`maxDepth` = `impact_depth`; `summaryOnly:
186true` first for hub symbols, then drill in — an allowed repeat). Record the
187 d=1 items — the **direct (depth-1) dependents** — the plan must account
188 for every one of them.
1894. `trace {from, to}` — when the task hinges on _how A reaches B_, one call
190 instead of chained context hops.
1915. Statement-level PDG — Phase 3, for the functions the change centers on.
1926. `cypher` — last resort, only for a precise graph question the tools above
193 cannot express. Read `gitnexus://repo/{name}/schema` first; anchor and
194 LIMIT every query.
1957. `detect_changes {scope}` — only when planning against existing uncommitted
196 or branch work.
197
198Do not run every tool by default. A local test fix may finish the ladder at
199step 2.
200
201## Phase 3 — Statement-level PDG slice
202
203For the 1–3 functions most central to the change, build a bounded **PDG
204context slice**. Read `references/pdg-slice.md` and follow it — it owns the
205tool calls, inclusion criteria, depth bounds, slice schema, the security and
206performance modes, and the no-PDG-layer fallback.
207
208## Phase 4 — Targeted source verification
209
210GitNexus said where to look; now confirm what is there. Using ordinary file
211reads (exact line ranges, not whole files unless genuinely required):
212
213- Read every source range the plan will cite: signatures, branch conditions,
214 state mutations, error paths, nearby comments that change behavior. Compact
215 plans cite less — verify what they cite, don't expand the citation set to
216 have more to verify.
217- Read the tests GitNexus associated with the primary symbols; never claim a
218 test exists without having located it.
219- Verify the build/test commands the plan will name actually exist
220 (package.json scripts / CI workflows), and prefer the script form that
221 carries its prerequisites (pre-hooks) over invoking underlying binaries
222 directly.
223- Check repo conventions that constrain the change (AGENTS.md, GUARDRAILS.md,
224 lint/build config) — only the parts the change touches.
225- Mark each ledger symbol `source_verified: true` as you go. **A symbol that
226 is named in Proposed Changes must be source-verified.**
227- On graph/source disagreement: trust source, record the discrepancy in the
228 ledger and the plan, recommend re-indexing. Never present stale graph data
229 as fact.
230- Immediately before composition, recompute the versioned
231 `evidence_provenance` snapshot by invoking
232 `scripts/evidence-provenance.mjs` exactly as specified in
233 `references/evidence-provenance.md`: the
234 canonical global dirty digest over all dirty paths and the sorted manifest
235 of every cited path, including object kind and
236 HEAD/index/worktree/untracked layer digests. Re-read any citation that
237 changed during planning. Exclude only the generated plan path.
238
239Evidence hierarchy, strongest first: current source and config → current tests
240and executable behavior → compiler/build/lint output → GitNexus graph and PDG
241→ documentation and comments.
242
243## Phase 5 — Compose the plan
244
2451. Read `references/plan-template.md` and fill the category's form — compact
246 (core sections, ≤80 lines excluding the pack) or full (all 13 sections) —
247 from the ledger, tagging claims with the template's four classes —
248 `[verified]`, `[graph]`, `[inferred]`, `[assumed]` — and routing open
249 questions to §12.
2502. Build the implementation context pack per `references/context-pack.md`
251 (this is section 11 of the plan), including mandatory
252 `evidence_provenance` in compact and full forms.
2533. Set `generated_plan_path` to
254 `docs/plans/YYYY-MM-DD-gitnexus-plan-<slug>.md` under the root of the repo
255 being planned (the Phase 1 target repo, not necessarily the cwd); use a
256 3–5-word kebab-case slug and repo-relative paths inside the document.
257 Compose the complete document without creating that destination, then
258 pipe its exact UTF-8 bytes to `scripts/evidence-provenance.mjs write-plan`
259 as specified in `references/evidence-provenance.md`. The helper safely
260 creates missing parent directories. Initial planning must not pass
261 `--replace`. A safe-write failure blocks plan publication: report it and
262 do not write directly, choose an external destination, or weaken the
263 repo-relative provenance contract. The snapshot and writer commands apply
264 the same strict generated-plan filename/date validator; do not substitute a
265 source, `.git`, or arbitrary `docs/plans/` path in either invocation.
2664. Present in chat: objective, proposed-changes summary, implementation
267 sequence, top risks, open questions, and the plan file path. Do not paste
268 the whole document into chat.
269
270## Deepen mode
271
272`/gitnexus-plan deepen <plan-path>` strengthens an existing plan in place
273instead of creating a new one:
274
2751. Resolve the target repository and normalized repo-relative plan candidate,
276 then load it with `scripts/evidence-provenance.mjs read-plan --repo <root>
277--generated-plan <candidate>` exactly as specified in
278 `references/evidence-provenance.md`. Reject a missing, external, escaping,
279 symlinked, or differently scoped path. Decode and parse only the receipt's
280 exact `plan_bytes_base64`; retain its canonical `generated_plan_path` and
281 `plan_digest` unchanged for the entire Deepen session.
2822. Re-run Phase 1 in full — analyzer provenance check and freshness gate (a
283 Deepen run is its own session, with its own refresh budget).
2843. **Re-anchor before re-pinning.** Recompute the plan's global dirty digest
285 and cited-path manifest as well as comparing its old HEAD pin with current
286 HEAD. Changed, renamed, deleted, mixed, or newly absent cited paths get
287 their ranges re-read — or the claim downgraded — _before_ the pin and
288 provenance snapshot move. Moving only the commit pin silently launders
289 dirty or stale claims as verified.
2904. Escalate to `depth: deep` (impact_depth 3, clusters/processes read)
291 unless the invocation overrides knobs explicitly.
2925. Seed the ledger from the plan's §11 pack, then re-verify: every
293 `[graph]`/`[inferred]` claim gets a targeted pass toward `[verified]`;
294 every `[assumed]` claim is resolved or kept with its reason; direct
295 (d=1) dependent accounting is re-checked against the refreshed graph;
296 PDG slices are built or expanded for the central functions when the
297 layer is present.
2986. **Reconcile execution state.** If `gitnexus-work` already landed commits
299 for this plan (a mid-execution route-back), mark the §7 steps present at
300 HEAD as completed and re-sequence the remainder — the rewritten plan must
301 be executable from the top without redoing landed steps.
3027. Strengthen whatever the deeper pass showed thin — test scenarios, risks,
303 Definition of Done — and carry claim-tag upgrades through the prose.
3048. Rewrite the **same canonical file** through
305 `scripts/evidence-provenance.mjs write-plan --replace
306--expected-plan-path <retained-read-plan-path>
307--expected-plan-digest <retained-read-plan-digest>`: same 13 sections,
308 context pack kept in sync, evidence header updated. `--replace` is reserved
309 for Deepen mode, and both expected values must come from the same read-plan
310 receipt; any digest/path mismatch blocks publication. Retain the successful receipt's
311 `prior_plan_backup_git_path`; it names the verified Git-admin backup of the
312 displaced plan. Summarize the delta in chat: claims upgraded, claims that
313 failed re-verification, sections changed, and that backup path.
314
315## Configuration
316
317Baseline defaults — the Phase 0 category posture overrides them, and inline
318`key:value` tokens before the task text override both (the repo has no
319skill-config file mechanism; invocation args are the mechanism):
320
321| Knob | Default | Meaning |
322| --------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
323| `depth` | by category | `narrow` = `impact_depth` 1, PDG only if one function is clearly central; `default` = this table; `deep` = `impact_depth` 3 + clusters/processes read |
324| `form` | by category | `compact` (core sections + mini-pack, ≤80 lines excl. pack — see `references/plan-template.md`) or `full` (all 13 sections) |
325| `impact_depth` | 2 | `maxDepth` for `impact` |
326| `pdg_data_depth` | 2 | Data-dependence hops in the PDG slice |
327| `pdg_control_depth` | 2 | Control-dependence hops in the PDG slice |
328| `max_primary_symbols` | 5 | Ledger budget (active symbols; discards don't count) |
329| `max_related_symbols` | 20 | Ledger budget (active symbols; discards don't count) |
330| `max_snippet_lines` | 30 | Longest source excerpt quoted in the plan |
331| `freshness` | by category | `strict` (full-plan categories) = refresh a stale index (and a missing PDG layer) with `analyze --index-only [--pdg]` before relying on the graph; `accept` (compact categories) = plan on the current graph, source-weighted and labelled, refreshing only if a graph claim becomes load-bearing |
332
333## Fallback mode (GitNexus or PDG unavailable)
334
3351. Say so, first thing, in chat and in the plan.
3362. Use targeted repo exploration (grep/glob/reads) to approximate callers,
337 dependencies, execution flow, state changes, and related tests.
3383. Label every such finding **source-derived** in the plan — never present it
339 as graph-derived, and never fabricate statement-level edges.
3404. Recommend `analyze --index-only` (add `--pdg` for the PDG layers) via
341 the resolved runner — `node .gitnexus/run.cjs`, installed `gitnexus`, or
342 `npx gitnexus` — when it would materially raise confidence.
343
344## Skill feedback
345
346If this run exposed friction in the instructions, include concise feedback in
347the final response. Feedback is chat-only: do not append evaluation learnings,
348edit benchmark data, or modify this skill during a live planning task.