@antoneeo/agentic-sdlc-skill 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  Tutte le modifiche significative a questa skill saranno documentate in questo file.
4
4
 
5
+ ## [1.15.0] - 2026-07-19 (Write Triggers + Code-Comprehension Guides)
6
+ ### Added
7
+ - **Code-comprehension guides (`source_kind: code`)** — a new guide kind the agent writes **autonomously** (a duty, no proposal) when it recognizes a high-complexity component / feature / abstraction layer with no CURRENT guide: a source-faithful map of how the thing works, so the next session starts with the model instead of re-deriving it and breaking the component from partial understanding. Reuses the ENTIRE guide machinery (snapshot + `source_hash` + `stale` + router + fidelity markers) — the source is verbatim CODE EXCERPTS in `.sources/` instead of a handed document; `sdlc_check.py` is unchanged. The skill-wide "propose, never a silent write" rule is relaxed for THIS kind only (additive, code-anchored, reversible); the anti-hallucination floor holds — every claim traces to a code excerpt. Triggered by concrete signals (high comprehension cost, high fan-in, non-obvious flow, prior / repeated-across-sessions breakage from partial understanding, non-local rationale) and by **chronic fragility** (a component breaking repeatedly across sessions → write the guide AND escalate a refactor as its own L3; stop patching). Touches `guides.md` §1–§6, `SKILL.md` (4th "Comprehend" moment + Write-Triggers `code` row + consult wording), `templates.md` (`source_kind` + comprehension repertoire), `debugging.md` (capture-the-model + chronic-fragility). Positioned under Vision **Layer A** (Documentation-First lifecycle applied to code understanding), distinct from Layer D's user-indication operative guides.
8
+ - **`SKILL.md` §Write Triggers** — a mechanical document→trigger→phase table, symmetric to Rule Zero: triage decides IF documentation is due, this table decides WHICH document each event produces. One event, one destination; create-or-update, never duplicate. It is the authoritative write index; the workflow phases point to it.
9
+
10
+ ### Changed
11
+ - **Bootstrap set made explicit (Phase 1)** — the named doc set (`README.md`, the three Vision docs as DRAFT, `strategic/architecture.md`, `strategic/existing_features.md`, Standalone `audit/audit_plan.md`, then regenerate `INDEX.md`) replaces the vague "minimal documents".
12
+ - **`handoff.md` write trigger + session-end rule** — mandatory at every L3 closure, and when a session ends with an ANALYSIS still IN_PROGRESS; the Phase-4 Diary trigger now names "session ends with work unfinished". Mirrored in `templates.md`.
13
+ - **`VISION_[feature].md` retroactive trigger** — fires when creating the SECOND `ANALYSIS_*` on the same theme (no foresight required).
14
+ - **ADR trigger unified** across Standalone (`architecture/`) and Hybrid (devPNT DB); no decision, no ADR.
15
+ - **`features_history.md` regime** pinned to `sdlc_check.py index` (prose discipline only without Python).
16
+ - **"Understand before acting"** now names cross-session source-memory rot — re-read a component you think you remember; trust the code (and its comprehension guide), not memory.
17
+ - **SKILL.md thesis line** — the skill's one-line "why": prevent *myopia* (acting from partial understanding).
18
+ - **Blast-radius enumeration is an authoring duty (Phase 3)** — mechanically enumerate every consumer of a signature-changed / multi-caller symbol up front with the symbol-graph, not as a review finding; `debugging.md` root-cause traces callers the same way (not text search).
19
+
20
+ ### Process note
21
+ Doc-only: no `sdlc_check.py` or packaging change; validator behavior untouched (the packaged file allowlist is unchanged). Standalone L3 (devPNT off this session — locked on another project). Governed by `ai_docs/solutions/ANALYSIS_comprehension_guides.md` (F-015), Vision decision **B** (comprehension homed under Layer A, Layer D's differentiator untouched). Validated by TWO independent blind comprehension tests (fresh agent, skill-only, no hints): the new trigger is discoverable + correct, and the adversarial (refuses a general-knowledge guide) and autonomy-boundary (the autonomy relaxation does not leak to refactors or operative guides) probes pass; 6 findings surfaced across the two rounds and all fixed. Eval battery 52/52 green; `validate` 0 errors.
22
+
5
23
  ## [1.14.0] - 2026-07-08 (M6: Vision Actors — a characterized cast in the Vision)
6
24
  ### Changed
7
25
  - **Vision defines Actors.** The Vision templates replace the flat `## Target Users` / `## Users or Stakeholders` with a first-class `## Actors` element: one light line per actor — **Role** — primary goal; good UX = what a good experience means to them. An Actor is defined ONCE in the Vision (project or feature) and REFERENCED by each use-case / `D-UC` (actor = who they are, use-case = what they do) — anti-DRY, and enough to design the intended UX for concrete roles instead of an implicit "user". A feature may declare its own feature-local cast for internal-tooling work.
package/README.md CHANGED
@@ -4,10 +4,10 @@
4
4
 
5
5
  ## Key Features
6
6
 
7
- - **Risk-proportional workflow**: L1/L2/L3/Spike triage avoids heavyweight process for trivial work.
7
+ - **Risk-proportional workflow**: L1/L2/L3/Spike triage avoids heavyweight process for trivial work, with a symmetric **Write Triggers** table mapping each event to the document it produces (one event, one destination).
8
8
  - **Vision-guided governance**: Standalone projects use `ai_docs/vision/`; Hybrid projects use devPNT `M-VISION` as the milestone north star. The Vision names its **Actors** — the cast a feature serves, one light line each — so UX is designed for concrete roles, not an implicit "user".
9
9
  - **Execution disciplines**: explicit TDD (RED/GREEN/REFACTOR), systematic debugging, an L3 spec-elicitation round, and a single code-review definition wired into the workflow phases.
10
- - **Operative guides + agent-global KB**: distil user-provided indications into source-faithful `ai_docs/reference/GUIDE_*.md` — consulted before operative work, proposed after reusable work shared cross-project via `~/.agentic-sdlc`.
10
+ - **Operative + comprehension guides + agent-global KB**: distil user-provided indications into source-faithful operative `GUIDE_*.md` (`source_kind: document`), and let the agent autonomously author **code-comprehension guides** (`source_kind: code`) for complex components a source-faithful mental-model map that survives across sessions, so the next session doesn't re-derive and break the component from partial understanding. Consulted before work; shared cross-project via `~/.agentic-sdlc`.
11
11
  - **Opt-in subagent execution**: an approved design projects into a validated executable plan an orchestrator can drive through subagents.
12
12
  - **Self-activating**: a SessionStart hook emits repo-sourced orientation; a deterministic self-eval battery guards the skill's own doctrine as the release gate.
13
13
  - **Standalone complete**: works fully with local `ai_docs/` without requiring devPNT.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-sdlc-skill",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Documentation-First SDLC protocol with triage, Vision governance and optional devPNT integration.",
5
5
  "author": "Antonio Pinto (https://github.com/Antoneeo)"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antoneeo/agentic-sdlc-skill",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Documentation-First SDLC protocol for Claude Code, Gemini CLI, Google Antigravity and Codex with risk triage, Vision governance, installed support files and optional devPNT integration.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -7,6 +7,8 @@ copyright: (c) 2026 Antonio Pinto
7
7
 
8
8
  # Agentic SDLC
9
9
 
10
+ **Why this skill exists:** to prevent *myopia* — acting from partial understanding, where a change breaks what it did not account for and hard-won knowledge evaporates between sessions. Triage, the Vision Gate, the documentation lifecycle and comprehension guides are all one defense against that.
11
+
10
12
  This skill guides software development with a Documentation-First process proportional to risk. It must work fully even without devPNT. When devPNT is available and configured for the current project, the skill works in symbiosis with its governance: M-VISION, Master Plan, Action Plan and versioned artifacts become the authoritative frame for milestones and implementation.
11
13
 
12
14
  Support files in the skill directory:
@@ -19,7 +21,7 @@ Read these files only when needed. `SKILL.md` is the operating contract; the sup
19
21
 
20
22
  ## Technical Values
21
23
 
22
- - **Understand before acting:** do not modify code without understanding root cause, constraints and current shape.
24
+ - **Understand before acting:** do not modify code without understanding root cause, constraints and current shape — including re-reading a component you think you remember, because your model of it rots between sessions; trust the code (and its comprehension guide), not memory.
23
25
  - **Preserve architectural coherence:** respect existing layers, responsibilities, naming, patterns and conventions.
24
26
  - **Apply DRY and simplicity:** do not duplicate logic or knowledge; abstract only when it reduces real complexity.
25
27
  - **Preserve quality:** every change must maintain or improve stability, testability and maintainability.
@@ -36,7 +38,7 @@ Always classify the request before choosing the process. Declare the chosen leve
36
38
  | Level | Criteria | Required process |
37
39
  |---|---|---|
38
40
  | **L1 - Trivial** | About 10 lines in 1-2 files; no API, dependency or new-behavior change; typos or fixes restoring already-expected behavior | Implement. Run relevant existing tests. No new documents. |
39
- | **L2 - Small** | Clear root cause; at most 3 files; no new dependency or public API; low risk | Mini-analysis in the message: objective, impact, security, tests. Tests mandatory. No new document, except updating an existing analysis/handoff if useful. |
41
+ | **L2 - Small** | Clear root cause; at most 3 files; no new dependency or public API; low risk | Mini-analysis in the message: objective, impact, security, tests. Tests mandatory. No new document, except updating an existing analysis on the same topic, or the handoff (see Write Triggers). |
40
42
  | **L3 - Significant** | More than 3 files, APIs/contracts, new dependency, user-visible behavior, security-sensitive area, architectural change or non-obvious design | Full workflow: Vision Gate, analysis, plan, implementation, tests, closure. |
41
43
  | **Spike** | Time-boxed exploration to reduce uncertainty | Code not mergeable into main. Outcome in `ai_docs/solutions/SPIKE_[topic].md`. For production, reclassify as L2 or L3. |
42
44
 
@@ -46,6 +48,24 @@ Cross-cutting rules:
46
48
  - When in doubt, pick the higher level.
47
49
  - The full audit does not start for L1/L2 unless explicitly requested.
48
50
 
51
+ ## Write Triggers
52
+
53
+ Triage decides IF documentation is due; this table decides WHICH document each event produces, and when. **One event, one destination:** when the trigger fires and the document does not exist, create it; when it exists, update it — never duplicate it. This table is the authoritative write index — the workflow phases carry the surrounding procedure and point here for the trigger.
54
+
55
+ | Document | Write trigger | Phase |
56
+ |---|---|---|
57
+ | `solutions/ANALYSIS_[feature].md` | Every L3, after elicitation and before any code. On topic match with an existing analysis, update that one instead of a new file. | 3 |
58
+ | `solutions/SPIKE_[topic].md` | Closing any Spike — including a failed one (a negative outcome is still an outcome). | — |
59
+ | `vision/features/VISION_[feature].md` | Feature known multi-milestone at analysis time, OR the retroactive trigger: you are about to create the SECOND `ANALYSIS_*` on the same theme — extract the shared feature vision first, then let both analyses reference it. | 3 |
60
+ | `audit/handoff.md` | Mandatory at every L3 closure, and at session end when an ANALYSIS is still IN_PROGRESS (even without closure); discretionary after an L2 when useful. Refresh Date / Branch / active features / next step; ≤ 20 lines. | 5 / session end |
61
+ | `audit/audit_plan.md` (Standalone) | Bootstrap, and whenever a mapped area changes state (`sdlc_check.py mark` records the reference — git hash, else UTC timestamp). | 1 |
62
+ | `reference/GUIDE_[topic].md` (`source_kind: document`) | Origin+purpose test (`guides.md`), or a proactive proposal the user accepted. Propose, never a silent write, never from model knowledge. | 4 / 5 |
63
+ | `reference/GUIDE_[topic].md` (`source_kind: code`) | Recognized high-complexity component/feature/layer with no CURRENT guide — including one that breaks repeatedly across sessions → **duty to write autonomously** (no proposal; additive, code-anchored, reversible). Fidelity floor: every claim traces to a code excerpt. Signals + guard-rails: `guides.md` §1. | any |
64
+ | ADR — `architecture/` (Standalone) or devPNT DB (Hybrid) | An architectural decision was taken (new pattern, layer or contract change, structural dependency): record it at closure, before DONE. No decision, no ADR. | 5 |
65
+ | `strategic/architecture.md`, `strategic/existing_features.md` | Bootstrap; update at closure when the stack or the feature catalog actually changed. | 1 / 5 |
66
+ | `vision/project_vision.md`, `roadmap.md`, `principles.md` | Bootstrap, as `Status: DRAFT`; promoted to APPROVED only by explicit user confirmation. | 1 / 2 |
67
+ | `INDEX.md`, `reference/INDEX.md`, `strategic/features_history.md` | Never by hand: regenerated by `sdlc_check.py index` at closure when canonical docs or guides changed (prose discipline where the validator is not adopted). | 5 |
68
+
49
69
  ## Operating Modes
50
70
 
51
71
  ### Full Standalone
@@ -56,7 +76,7 @@ Source of truth:
56
76
  - Vision: `ai_docs/vision/project_vision.md`, `roadmap.md`, `principles.md`.
57
77
  - Features/analyses: `ai_docs/solutions/ANALYSIS_[feature].md`.
58
78
  - Audit/handoff: `ai_docs/audit/`.
59
- - Feature history: `ai_docs/strategic/features_history.md`, manual or generated by the validator, depending on the structure the project adopts.
79
+ - Feature history: `ai_docs/strategic/features_history.md` generated by `sdlc_check.py index` (kept by hand as a prose discipline only in environments without Python).
60
80
 
61
81
  Standalone mode is not reduced: it must handle audits, features, significant bugs, tests, handoffs and closure without devPNT.
62
82
 
@@ -157,7 +177,7 @@ gate) instead of requiring an IN_PROGRESS ANALYSIS.
157
177
  - Read `ai_docs/audit/handoff.md` if it exists; if its Date/Branch are inconsistent, treat it as history.
158
178
  - Read `ai_docs/README.md` (curated must-reads) and `ai_docs/INDEX.md` (generated manifest of all canonical docs) to know what exists before exploring the code. `solutions/` and `audit/` are not indexed per file: search them with glob/grep.
159
179
  - Optional: a SessionStart hook (`ENFORCEMENT.md` §4) can emit this orientation automatically at session start (README + INDEX + guide router + handoff + triage reminder); when it is not wired, do these reads manually as above. The hook is a convenience, never a requirement — it introduces no Python dependency for the process itself and fails open (a missing/empty `ai_docs/` never blocks the session).
160
- - If `ai_docs/` is missing or incomplete, create the structure and minimal documents by analyzing the project in batches.
180
+ - If `ai_docs/` is missing or incomplete, create the structure and the **bootstrap set** by analyzing the project in batches: `README.md`, the three `vision/` docs (`Status: DRAFT`), `strategic/architecture.md`, `strategic/existing_features.md` and — Standalone — `audit/audit_plan.md`; then regenerate `INDEX.md`. Nothing else is mandatory at bootstrap (per-document triggers: Write Triggers).
161
181
  - In Standalone use `ai_docs/audit/audit_plan.md` for mapping and state.
162
182
  - In Hybrid prefer the devPNT/KL mapping when available; do not duplicate plan governance.
163
183
  - For detailed templates use `templates.md`.
@@ -179,12 +199,14 @@ Hybrid:
179
199
 
180
200
  For any L3, run the spec elicitation round in `elicitation.md` BEFORE drafting the analysis (skip path inside — one-line note when the spec is already complete).
181
201
 
202
+ **Blast-radius enumeration is an authoring duty, not a review finding.** Before writing the Impact (the list of what changes), for every symbol whose signature you change, thread a new field through, or that has more than one caller: mechanically enumerate EVERY consumer with the best symbol-graph tool your toolchain offers — an LSP/IDE call hierarchy or a find-usages / call-graph capability — with `grep` only as a last-resort fallback, and list the full set in the Impact. Anchor to symbol identity, not line numbers (they rot). This is deterministic and cheap: doing it up-front collapses the review into one pass, instead of the reviewer returning "you missed a consumer" one round at a time. Leaving completeness to the closure review is the myopia failure this whole workflow exists to prevent.
203
+
182
204
  Standalone L3:
183
205
  - Before creating a new `ANALYSIS_[feature].md`, search `ai_docs/solutions/` with glob/grep for an existing analysis on the same topic: if there is one, update it instead of duplicating it.
184
206
  - Create or update `ai_docs/solutions/ANALYSIS_[feature].md`.
185
207
  - Minimum sections: Objective, Feature Vision (or Vision Alignment), Impact, Security and Threat Model, Action Plan, Test Strategy, Diary/Current State.
186
208
  - Build the Impact/solution **on** the Vision, the use-cases/user-needs and the Security & Threat Model — read and trace to them first, and state the trace (which actor / use-case / threat / benefit each part serves) so the closure review (`review.md`) can verify conformance. Do not draft the Impact in isolation.
187
- - For features spanning multiple milestones or multiple analyses, also create `ai_docs/vision/features/VISION_[feature].md`.
209
+ - For a feature known to span multiple milestones, also create `ai_docs/vision/features/VISION_[feature].md`; the retroactive case (extract it when the SECOND `ANALYSIS_*` on a theme appears) is in Write Triggers.
188
210
 
189
211
  Hybrid L3:
190
212
  - Restore the Master Plan, Action Plan and linked documents.
@@ -197,11 +219,11 @@ Hybrid L3:
197
219
  - Isolate the work: run an L3 change on its own branch. In Hybrid, prefer a git worktree from the start — a running devPNT server locks `.devpnt/*.db` and blocks in-place branch switches/merges in the primary worktree.
198
220
  - Modify surgically, consistently with the plan.
199
221
  - Implementation work follows the TDD discipline in `tdd.md` (RED/GREEN/REFACTOR — the L2/L3 default; record the reason when it does not apply).
200
- - Before implementing (L2/L3; L1 exempt), **consult the guide router** for a guide covering the task and read it first the consult trigger (`guides.md` §0, summarized under `## Operative Guides`). A targeted description match, not a blanket read.
222
+ - Before implementing (L2/L3; L1 exempt), **consult the guide router** for a guide covering the task — operative, or a comprehension map of the component you are about to touch — and read it first (the consult trigger, `guides.md` §0, summarized under `## Operative Guides`). A targeted description match, not a blanket read.
201
223
  - If the environment does not allow automated tests, declare the alternative verification and the reason.
202
224
  - For bugs (L2/L3), follow the systematic debugging method in `debugging.md`.
203
- - Circuit breaker: after 3 consecutive runs without progress on the tests, stop, switch to the systematic method in `debugging.md`, and ask for instructions if still stuck.
204
- - Update the ANALYSIS Diary or the Action Plan when you complete milestones, hit blockers or change decisions.
225
+ - Circuit breaker: after 3 consecutive runs without progress on the tests, stop, switch to the systematic method in `debugging.md`, and ask for instructions if still stuck. `debugging.md` also covers **chronic fragility** — a component that breaks repeatedly across sessions is a comprehension + complexity signal (write the `source_kind: code` guide AND escalate a refactor), not a fourth patch.
226
+ - Update the ANALYSIS Diary or the Action Plan when you complete milestones, hit blockers, change decisions, or a session ends with work unfinished.
205
227
  - **Opt-in subagent execution**: for an L3 with an approved design, the orchestrator MAY execute the work via subagents per `dispatch.md`, gated by `sdlc_check.py plan validate` ("no valid plan, no dispatch"); default stays same-session. Hybrid: the executable `PLAN_[feature].md` is `derived-from` the accepted E-TDD, never independently authored.
206
228
 
207
229
  ### 5. Closure
@@ -211,6 +233,7 @@ Hybrid L3:
211
233
  - Verify alignment with the local Vision or the devPNT M-VISION.
212
234
  - If the work was governed by user-provided indications and is reusable, **PROPOSE distilling a guide** (proactive trigger, `guides.md` §1) — a proposal for the user, never a silent write, never from model knowledge.
213
235
  - Update only the documents actually impacted.
236
+ - **Update `audit/handoff.md`** — mandatory at every L3 closure (Date, Branch, active features, next step; ≤ 20 lines). The session-end rule and the L2 case: Write Triggers.
214
237
  - **Aligned indexes (Poka-Yoke)**: if you created, moved or removed canonical documents (`vision/`, `reference/`, `architecture/`, `functional/`, `strategic/`):
215
238
  - regenerate the manifest with `sdlc_check.py index` (writes `ai_docs/INDEX.md`) — never write it by hand;
216
239
  - if the document is a must-read, add/update its line in the curated `README.md`;
@@ -218,7 +241,7 @@ Hybrid L3:
218
241
  - if you created a new canonical subdirectory, give it a purpose in `README.md`.
219
242
  A canonical doc that is unindexed or lacks `status` = dirty closure (`sdlc_check.py check` fails/warns). Do not declare DONE until it is clean. Details: section "ai_docs documents".
220
243
  - guides created or changed: `sdlc_check.py index` regenerates BOTH manifests (`ai_docs/INDEX.md` and the guide router `ai_docs/reference/INDEX.md`) in one run.
221
- - In Hybrid propose ADR/KL updates when there were architectural decisions.
244
+ - If an architectural decision was taken (new pattern, layer or contract change, structural dependency), record an ADR before DONE — Standalone in `architecture/`, Hybrid propose the ADR/KL update in the devPNT DB. No decision, no ADR (Write Triggers).
222
245
  - In Standalone, if the project adopts `sdlc_check.py`, run `python <skill_dir>/scripts/sdlc_check.py check --root <project_root>` or the equivalent local copy.
223
246
  - Updated documents must travel in the same commit/PR as the code they describe.
224
247
  - **Branch/worktree hygiene**: an L3 ran on its own branch (Phase 4) — close it with an explicit merge decision (merge, keep open, or discard) and clean up the branch/worktree; never leave orphan branches. In Hybrid, the running devPNT server locks `.devpnt/*.db`, so the merge is done from a separate git worktree or via a ref-only push, never an in-place branch switch in the primary worktree.
@@ -250,10 +273,11 @@ Legacy note: the validator also accepts the deprecated Italian frontmatter keys
250
273
 
251
274
  ## Operative Guides
252
275
 
253
- Guides are **consulted, created, and proposed** — three moments; the mechanics live once in `guides.md`:
276
+ Guides are **consulted, created, proposed, and (for code) authored for comprehension** — four moments; the mechanics live once in `guides.md`. Two source kinds: `document` (user indications, operative) and `code` (a comprehension map of a complex component):
254
277
  - **Consult (before acting):** before operative L2/L3 work (L1 exempt), check the guide router for a guide covering the task and read the match first — a targeted description match, never a blanket read. → `guides.md` §0.
255
- - **Create (from user indications):** the origin+purpose test below.
278
+ - **Create (from user indications):** the origin+purpose test below (`source_kind: document`).
256
279
  - **Propose proactively (after success):** after reusable, user-indication-governed work, PROPOSE distilling a guide — a proposal, never a silent write, never from model knowledge. → `guides.md` §1.
280
+ - **Comprehend (code, autonomous):** when a component/feature/layer is high-complexity and no CURRENT guide covers it, it is your DUTY to WRITE a `source_kind: code` comprehension guide autonomously — no proposal (additive, code-anchored, reversible); every claim traces to a code excerpt. Signals + guard-rails: `guides.md` §1.
257
281
 
258
282
  Trigger test: the user hands over indications to follow (origin = user, not model
259
283
  knowledge) meant to govern how the agent operates (purpose = operative), not just
@@ -16,7 +16,11 @@ mechanism.
16
16
  unrelated setup, unrelated data, unrelated code paths. Bisect (recent
17
17
  commits, code paths, input ranges) when the boundary is unclear.
18
18
  3. **Root cause — name the mechanism.** State in one sentence why the
19
- observed behavior happens, tracing the actual execution path. **MUST NOT
19
+ observed behavior happens, tracing the actual execution path. Trace it by
20
+ enumerating the real callers/consumers of each suspect symbol with the best
21
+ symbol-graph tool your toolchain offers — an IDE/LSP call hierarchy or a
22
+ find-usages / call-graph capability — not text search; `grep`
23
+ under-enumerates and hides the very consumer that breaks. **MUST NOT
20
24
  patch a symptom without naming the mechanism; why: symptom patches recur
21
25
  and stack** — the same underlying defect resurfaces elsewhere, and each
22
26
  unexplained patch makes the next investigation harder, not easier.
@@ -25,7 +29,24 @@ mechanism.
25
29
  before applying the fix, or by temporarily reverting it) and passes after.
26
30
  A regression test that was never confirmed to fail proves nothing.
27
31
  6. **Run the relevant suite for collateral.** A root-cause fix can change
28
- behavior other callers depend on; check them before closing.
32
+ behavior other callers depend on; enumerate those callers with the
33
+ symbol-graph (step 3), not from memory, and check them before closing.
34
+
35
+ **Capture the model you had to rebuild.** If naming the mechanism (step 3) forced
36
+ you to reconstruct the mental model of a complex component that no guide documents —
37
+ tracing it across files because it was written down nowhere — that is the
38
+ comprehension trigger (`guides.md` §1): it is your duty to write the `source_kind:
39
+ code` guide, so the next debugger starts with the map you just paid to build.
40
+
41
+ **Chronic fragility is a signal, not a task to grind.** If a component breaks
42
+ *repeatedly across sessions* and its complexity is no longer under control, stop
43
+ treating each break as an isolated bug — that pattern has two duties, not one:
44
+ 1. **Understand** — write the `source_kind: code` comprehension guide (above) so the
45
+ understanding stops evaporating between sessions.
46
+ 2. **Escalate the complexity itself** — STOP stacking patches on a component nobody
47
+ fully understands. Flag the fragility as tech debt and propose a dedicated
48
+ **refactor as its own L3** (Vision-gated), instead of a fourth fix. Continuing to
49
+ patch a component you keep breaking is the anti-pattern, not the fix.
29
50
 
30
51
  ## Circuit breaker integration
31
52
 
@@ -17,6 +17,14 @@ when a task needs detail. Two levels, both produced by this pipeline:
17
17
  A guide that restates the source at length is as wrong as a fragmented one:
18
18
  completeness is guaranteed by the book level, economy by the synthesis level.
19
19
 
20
+ **Two source kinds.** A guide's `source_kind` is either `document` (the default —
21
+ distilled from USER-PROVIDED indications; operative, "how to act") or `code`
22
+ (distilled from the project's own code; a comprehension map of a complex component,
23
+ "how it works"). Both are **source-faithful and snapshot-anchored** — the machinery
24
+ below (snapshot, `source_hash`, fidelity markers, router, `stale`) is identical; only
25
+ what is gathered into `.sources/` differs (a handed document vs verbatim code
26
+ excerpts). Where a rule applies to only one kind, it says so.
27
+
20
28
  ## 0. Consuming a guide (consult before acting)
21
29
 
22
30
  Guides only pay off if they reach the work they govern. **Before operative work,
@@ -68,6 +76,34 @@ a guide.
68
76
  a guide from general knowledge (the `distilled_from` fidelity constraint, §3,
69
77
  is absolute). This adds a moment to PROPOSE, not a new writer.
70
78
 
79
+ ### Comprehension trigger (code source, autonomous — a duty, not a proposal)
80
+
81
+ The two triggers above are for `source_kind: document` (the user hands material
82
+ over). There is a third, for `source_kind: code`: while doing L2/L3 work, when you
83
+ recognize that a component / feature / abstraction layer is **high-complexity** and
84
+ no CURRENT guide already covers it, it is your **duty to WRITE a comprehension
85
+ guide** — autonomously, no proposal, no human gate. The next session (or another
86
+ agent) must not have to re-derive the model you just paid to build, and then break
87
+ the component from partial understanding.
88
+
89
+ - **Why autonomous is allowed here** (it is NOT for `document` guides): a
90
+ comprehension guide is **additive, code-anchored and reversible** (git). It changes
91
+ no code, plan or governed artifact — so the skill-wide "propose, never a silent
92
+ write" rule is relaxed for THIS kind only. The anti-hallucination floor still holds:
93
+ §3 fidelity is absolute — every claim traces to a verbatim code excerpt in the
94
+ snapshot, never to your assumption about what the code does.
95
+ - **Recognize "high-complexity" by concrete signals** (any strong combination, not a
96
+ vibe): you had to trace one behavior across several files/modules (summaries were
97
+ not enough); high fan-in / large blast radius (many consumers); non-obvious control
98
+ or data flow (state machine, async/eventing, DI/plugin indirection, metaprogramming,
99
+ cross-cutting invariants); the area was already broken once — or **repeatedly
100
+ across sessions** — from partial understanding (handoff / diary / git shows it);
101
+ the "why" is not reconstructable from a single file.
102
+ - **Guard-rails (autonomous is not unconstrained).** Search first (§2.0 — one CURRENT
103
+ guide per topic, both routers). Honor the fidelity floor (§3). RECOMMEND the
104
+ independent guide-vs-source review (§5) — it matters more here, since no human gated
105
+ creation. Announce the autonomous write in the closure / handoff so it is visible.
106
+
71
107
  ## 2. Pipeline
72
108
 
73
109
  0. **Search before creating (DRY — one CURRENT guide per topic).** Before
@@ -118,7 +154,10 @@ a guide.
118
154
  scope is a LOCATION decision by the user, never a content taxonomy; KB
119
155
  created lazily with `.sources/` on the first agent-scope guide).
120
156
  2. **User confirms** the topic decomposition — including the fragmentation-risk
121
- assessment and scope decision — before any file is written.
157
+ assessment and scope decision — before any file is written. **`source_kind: code`
158
+ skips this gate**: the comprehension guide is written autonomously (§1
159
+ comprehension trigger). Still run the fragmentation/scope judgement yourself — just
160
+ do not block on confirmation.
122
161
  3. **Snapshot each source verbatim** into
123
162
  `ai_docs/reference/.sources/<slug>-<hash8>.md`:
124
163
  - `slug` derives from the topic (lowercase, hyphenated).
@@ -134,6 +173,13 @@ a guide.
134
173
  normalized hash stays stable either way).
135
174
  - The snapshot is verbatim: no paraphrasing, no reformatting beyond what is
136
175
  needed to save it as markdown.
176
+ - **For `source_kind: code`** the snapshot is the verbatim CODE EXCERPTS the guide
177
+ explains — the specific functions / classes / regions of the real files, each
178
+ labelled with its `path:symbol` (or `path:startLine-endLine`) — assembled into
179
+ the one `.sources/<slug>-<hash8>.md` and hashed identically. Copy the code
180
+ verbatim (no paraphrase); include ONLY the regions the guide covers, not whole
181
+ files, so `stale` tracks the code that matters. `distilled_from` records those
182
+ code paths.
137
183
  4. **Source-anchored SYNTHESIS (not restatement).** Select and compress what
138
184
  the source says into the operative essence — decision rules, invariants,
139
185
  the "where people go wrong" list — and POINT INTO the snapshot for the
@@ -145,9 +191,11 @@ a guide.
145
191
  summarize-and-expand, forbidden). A guide approaching the source's own
146
192
  length is a paraphrase, not a synthesis — wrong output.
147
193
  5. **Render per template** (`templates.md` → `## ai_docs/reference/GUIDE_[topic].md`):
148
- frontmatter with `source`, `distilled_from`, `source_hash` (the snapshot's
149
- SHA-256, matching what you just computed), optional `source_version`; body
150
- sections chosen from the repertoire, each with a fidelity marker.
194
+ frontmatter with `source_kind` (`document` | `code`), `source`, `distilled_from`,
195
+ `source_hash` (the snapshot's SHA-256, matching what you just computed), optional
196
+ `source_version`; body sections chosen from the repertoire (a `code` guide uses the
197
+ comprehension repertoire — how it works / control & data flow / invariants / where
198
+ it breaks), each with a fidelity marker.
151
199
  **Write for the two-level read**: the guide (synthesis) is small enough to
152
200
  be read WHOLE before acting; the snapshot (book) is where size lives and
153
201
  where readers grep/partial-read on demand, following the section markers.
@@ -161,6 +209,11 @@ a guide.
161
209
 
162
210
  ## 3. Fidelity rules (mandatory, the D5 constraint)
163
211
 
212
+ "The source" below means the SNAPSHOT — a handed document for `source_kind: document`,
213
+ verbatim code excerpts for `source_kind: code`. The constraint is identical for both:
214
+ never from UNVERIFIED knowledge. A code guide's every claim traces to the actual code
215
+ in the snapshot, never to your assumption about what the code does.
216
+
164
217
  - Only what the source supports goes in the guide. If the source is silent on
165
218
  something a reader might expect, mark the section `[not covered by source]`
166
219
  — never fill the gap from general knowledge.
@@ -200,5 +253,10 @@ state it explicitly when handing off a newly created guide.
200
253
  compares each guide's recorded `source_hash` against the live snapshot file
201
254
  and reports `[stale]` when they diverge — that is the signal to regenerate,
202
255
  not a manual freshness check.
256
+ - **`source_kind: code` freshness**: `stale` works unchanged (the code-excerpt
257
+ snapshot drifts when the code changes → regenerate). ADDITIONALLY, when you modify
258
+ the code a comprehension guide describes, refresh that guide in the SAME closure
259
+ (docs travel with the code) — do not wait for `stale` to catch it. A stale
260
+ comprehension guide is a confident-wrong map, worse than none.
203
261
  - **Agent-global KB guides** use the same pipeline and validator via
204
262
  `--root ~/.agentic-sdlc`; freshness via the same `stale` engine.
@@ -22,7 +22,10 @@ When a doc replaces another: the new one declares `supersedes:`, the old one swi
22
22
 
23
23
  ## ai_docs/reference/GUIDE_[topic].md
24
24
 
25
- Operative guide distilled from USER-PROVIDED indications (never from model knowledge).
25
+ A guide is either OPERATIVE (`source_kind: document` — distilled from USER-PROVIDED
26
+ indications, "how to act") or a COMPREHENSION map (`source_kind: code` — distilled from
27
+ the project's own code, "how a complex component works"). Never from model knowledge:
28
+ every claim traces to the snapshot (a handed document, or verbatim code excerpts).
26
29
  The guide is a SYNTHESIS — the compact training a reader takes in whole before acting;
27
30
  the verbatim snapshot in `ai_docs/reference/.sources/<slug>-<hash8>.md` is the book,
28
31
  reached on demand. `source_hash` is the snapshot's SHA-256. Every `##` section carries
@@ -36,7 +39,8 @@ the source's own length is a paraphrase, not a synthesis.
36
39
  ---
37
40
  description: One line, ≤160 chars — when to consult this guide.
38
41
  status: CURRENT
39
- source: Human-readable name of what the user provided.
42
+ source_kind: document # document (user indications, operative) | code (comprehension map)
43
+ source: Human-readable name of what the user provided (or the component, for source_kind: code).
40
44
  source_version: v1.2 # optional — only when the origin is versioned
41
45
  distilled_from: ai_docs/reference/.sources/topic-a1b2c3d4.md
42
46
  source_hash: <sha256 of the snapshot file>
@@ -56,8 +60,12 @@ overrides: GUIDE_topic.md # optional — only for a project guide overriding a
56
60
  <!-- the user's material does not address this: do not invent. -->
57
61
  ```
58
62
 
59
- Section repertoire (pick what the source supports): How to do X / How to verify /
60
- What NOT to do / What to watch out for / Core principles / When this applies.
63
+ Section repertoire (pick what the source supports):
64
+ - **`document` (operative):** How to do X / How to verify / What NOT to do / What to
65
+ watch out for / Core principles / When this applies.
66
+ - **`code` (comprehension):** How it works / Control & data flow / Key invariants /
67
+ Extension points / Where it breaks (failure modes) / Why it is shaped this way.
68
+ Every marker points into the code-excerpt snapshot: `[source: <slug>-<hash8>.md#path:symbol]`.
61
69
 
62
70
  ## ai_docs/README.md
63
71
 
@@ -273,6 +281,8 @@ States: PENDING (to analyze) | ANALYZED (analyzed, with reference) | SKIPPED (wi
273
281
 
274
282
  Just a pointer, ≤ 20 lines. The detail lives in the Diary of each ANALYSIS.
275
283
 
284
+ Written at every L3 closure AND at session end with work still IN_PROGRESS (see SKILL.md, Write Triggers).
285
+
276
286
  ```markdown
277
287
  # Handoff
278
288
  Date: 2026-06-11 (UTC)