opencode-swarm 7.58.0 → 7.58.1

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.
Files changed (36) hide show
  1. package/.opencode/skills/brainstorm/SKILL.md +142 -0
  2. package/.opencode/skills/clarify/SKILL.md +103 -0
  3. package/.opencode/skills/clarify-spec/SKILL.md +58 -0
  4. package/.opencode/skills/codebase-review-swarm/INSTALL.md +75 -0
  5. package/.opencode/skills/codebase-review-swarm/README.md +44 -0
  6. package/.opencode/skills/codebase-review-swarm/SKILL.md +65 -0
  7. package/.opencode/skills/codebase-review-swarm/agents/openai.yaml +6 -0
  8. package/.opencode/skills/codebase-review-swarm/assets/jsonl-schemas.md +239 -0
  9. package/.opencode/skills/codebase-review-swarm/assets/review-report-template.md +244 -0
  10. package/.opencode/skills/codebase-review-swarm/references/compatibility-and-research-notes.md +25 -0
  11. package/.opencode/skills/codebase-review-swarm/references/full-v7-source-prompt.md +2373 -0
  12. package/.opencode/skills/codebase-review-swarm/references/review-protocol-v8.2.md +310 -0
  13. package/.opencode/skills/codebase-review-swarm/scripts/init-review-run.py +134 -0
  14. package/.opencode/skills/codebase-review-swarm/scripts/validate-skill-package.py +62 -0
  15. package/.opencode/skills/consult/SKILL.md +16 -0
  16. package/.opencode/skills/council/SKILL.md +147 -0
  17. package/.opencode/skills/critic-gate/SKILL.md +59 -0
  18. package/.opencode/skills/deep-dive/SKILL.md +142 -0
  19. package/.opencode/skills/design-docs/SKILL.md +81 -0
  20. package/.opencode/skills/discover/SKILL.md +20 -0
  21. package/.opencode/skills/execute/SKILL.md +191 -0
  22. package/.opencode/skills/issue-ingest/SKILL.md +64 -0
  23. package/.opencode/skills/phase-wrap/SKILL.md +123 -0
  24. package/.opencode/skills/plan/SKILL.md +293 -0
  25. package/.opencode/skills/pre-phase-briefing/SKILL.md +69 -0
  26. package/.opencode/skills/resume/SKILL.md +23 -0
  27. package/.opencode/skills/specify/SKILL.md +175 -0
  28. package/.opencode/skills/swarm-pr-feedback/SKILL.md +192 -0
  29. package/.opencode/skills/swarm-pr-review/SKILL.md +884 -0
  30. package/dist/cli/index.js +1348 -1156
  31. package/dist/commands/command-dispatch.d.ts +1 -0
  32. package/dist/commands/index.d.ts +1 -0
  33. package/dist/commands/registry.d.ts +15 -14
  34. package/dist/config/bundled-skills.d.ts +25 -0
  35. package/dist/index.js +2797 -2602
  36. package/package.json +20 -1
@@ -0,0 +1,175 @@
1
+ ---
2
+ name: specify
3
+ description: >
4
+ Full execution protocol for MODE: SPECIFY -- spec creation, codebase reality checks, SME input, QA gate persistence, and optional council spec review.
5
+ ---
6
+
7
+ # Specify Protocol
8
+
9
+ This protocol is loaded on demand by the architect stub in src/agents/architect.ts. The architect prompt keeps only activation, action, and hard safety constraints; the full execution details live here.
10
+
11
+ ### MODE: SPECIFY
12
+ Activates when: user asks to "specify", "define requirements", "write a spec", or "define a feature"; OR `/swarm specify` is invoked; OR no `.swarm/spec.md` exists and no `.swarm/plan.md` exists.
13
+
14
+ 1. Check if `.swarm/spec.md` already exists.
15
+ - If YES (and this is not a call from the stale spec archival path in MODE: PLAN): ask the user "A spec already exists. Do you want to overwrite it or refine it?"
16
+ - Overwrite → ARCHIVE FIRST: read the existing spec, extract version (priority order): (1) from spec heading, look for patterns like "v{semver}" or "Version {semver}" in the first H1/H2; (2) from package.json version field in project root; create `.swarm/spec-archive/` directory if it does not exist; copy existing spec.md to `.swarm/spec-archive/spec-v{version}.md`; if version cannot be determined, use date-based fallback: `.swarm/spec-archive/spec-{YYYY-MM-DD}.md`; log the archive location to the user ("Archived existing spec to .swarm/spec-archive/spec-v{version}.md"); then proceed to generation (step 2)
17
+ - Refine → delegate to MODE: CLARIFY-SPEC
18
+ - If NO: proceed to generation (step 2)
19
+ - If this is called from the stale spec archival path (MODE: PLAN option 1) — archival was already completed; skip this check and proceed directly to generation (step 2)
20
+ 1b. Run CODEBASE REALITY CHECK for any codebase references mentioned by the user or implied by the feature. Skip if work is purely greenfield (no existing codebase to check). Report discrepancies before proceeding to explorer.
21
+ 2. Delegate to `the active swarm's explorer agent` to scan the codebase for relevant context (existing patterns, related code, affected areas).
22
+ 3. Delegate to `the active swarm's sme agent` for domain research on the feature area to surface known constraints, best practices, and integration concerns.
23
+ 4. Generate `.swarm/spec.md` capturing:
24
+ - First line must be: `# Specification: <feature-name>`
25
+ - Feature description: WHAT users need and WHY — never HOW to implement
26
+ - User scenarios with acceptance criteria (Given/When/Then format)
27
+ - Functional requirements numbered FR-001, FR-002… using MUST/SHOULD language
28
+ - Success criteria numbered SC-001, SC-002… — measurable and technology-agnostic
29
+ - Key entities if data is involved (no schema or field definitions — entity names only)
30
+ - Edge cases and known failure modes
31
+ - `[NEEDS CLARIFICATION]` markers for items where uncertainty could change scope, security, or core behavior, BUT ONLY after running the clarification funnel: (1) inventory all material uncertainties without numeric cap, (2) classify each as self_resolved/critic_resolved/research_needed/user_decision/deferred_nonblocking — **overconfidence guard:** if the default is not directly supported by user request, spec, or recorded context, classify as `user_decision` rather than `self_resolved`, (3) consult critic_sounding_board with candidate items — critic responds per SoundingBoardVerdict: UNNECESSARY→DROP, RESOLVE→RESOLVE, REPHRASE→REPHRASE, APPROVED→ASK_USER — **always-surface protection:** always-surface categories must not receive UNNECESSARY/DROP; override to APPROVED/ASK_USER, (4) record all resolved items as explicit assumptions in the spec, (5) use markers only for items that survive the funnel (ASK_USER or unresolved after critic consultation). Decision packet format: grouped by category, recommended defaults, blocking vs optional markers, impact of accepting default. Prefer informed defaults over asking
32
+ 5. Write the spec to `.swarm/spec.md`.
33
+ 5b. **QA GATE SELECTION (dialogue only).**
34
+ Ask the user which QA gates to enable for this plan before suggesting the next step.
35
+
36
+ Present the eleven gates with their defaults (DEFAULT_QA_GATES) as a single user-facing question. Offer the user a one-shot choice: accept defaults, or customize. The eleven gates are:
37
+ - reviewer (default: ON) -- code review of coder output
38
+ - test_engineer (default: ON) -- test verification of coder output
39
+ - sme_enabled (default: ON) -- SME consultation during planning/clarification
40
+ - critic_pre_plan (default: ON) -- critic review before plan finalization
41
+ - sast_enabled (default: ON) -- static security scanning
42
+ - council_mode (default: OFF) -- multi-member council gate (recommended for high-impact architecture, public APIs, schema/data mutation, security-sensitive code)
43
+ - hallucination_guard (default: OFF) -- when enabled, mandatory per-phase API/signature/claim/citation verification via critic_hallucination_verifier at PHASE-WRAP; phase_complete will REJECT phase completion unless .swarm/evidence/{phase}/hallucination-guard.json exists with an APPROVED verdict (recommended for claim-heavy or research-heavy work)
44
+ - mutation_test (default: OFF) -- when enabled, runs mutation testing on source files touched this phase via generate_mutants + mutation_test + write_mutation_evidence at PHASE-WRAP; FAIL verdict blocks phase_complete; WARN is non-blocking (recommended for projects with coverage gaps or safety-critical code)
45
+ - council_general_review (default: OFF) -- when enabled, MODE: SPECIFY runs convene_general_council on the draft spec before the critic-gate; the architect runs a curated web_search pass, dispatches council_generalist / council_skeptic / council_domain_expert in parallel with a shared RESEARCH CONTEXT block, deliberates on disagreements, and synthesizes the result directly into the spec (recommended for novel architecture, unclear best practices, or high-risk design decisions). Requires council.general.enabled: true and a configured search API key in the resolved config: global ~/.config/opencode/opencode-swarm.json, then project .opencode/opencode-swarm.json overrides.
46
+ - drift_check (default: ON) -- when enabled, mandatory per-phase drift verification via critic_drift_verifier at PHASE-WRAP; compares implemented changes against spec.md intent; hard-blocks phase_complete when spec.md exists and drift evidence is missing or REJECTED; advisory-only when no spec.md exists (recommended for all projects with a specification)
47
+ - final_council (default: OFF) - when enabled, after all phases complete the architect dispatches the same five phase-council members (`critic`, `reviewer`, `sme`, `test_engineer`, `explorer`) at project scope, collects `CouncilMemberVerdict` objects, and calls `write_final_council_evidence`. This is not General Council mode and does not require `council.general.enabled`.
48
+
49
+ One question, one message, defaults pre-stated. Wait for the user's answer.
50
+
51
+ If the user answered the gate question, immediately follow up with ONE more question: "How many coders should run in parallel? (default: 1, range: 1-4)" -- if the user says a number > 1, also write a `## Pending Parallelization Config` section to `.swarm/context.md` alongside the gate selection:
52
+ ```
53
+ ## Pending Parallelization Config
54
+ - parallelization_enabled: true
55
+ - max_concurrent_tasks: <user's number>
56
+ - council_parallel: false
57
+ - locked: true
58
+ - recorded_at: <ISO timestamp>
59
+ ```
60
+ If the user accepts the default (1), skip writing this section entirely -- serial execution is the default and needs no config.
61
+
62
+ After asking the parallelization question (regardless of whether the user chose serial or parallel), immediately follow up with ONE more question: "Commit frequency for completed tasks? (default: phase-level only; optional per-task checkpoint commit after each task completion)".
63
+
64
+ If the user chooses per-task commits, write this section to `.swarm/context.md`:
65
+ ```
66
+ ## Task Completion Commit Policy
67
+ - commit_after_each_completed_task: true
68
+ - recorded_at: <ISO timestamp>
69
+ ```
70
+ If the user keeps the default phase-level behavior, do not write this section.
71
+
72
+ <!-- BEHAVIORAL_GUIDANCE_START -->
73
+ GATE SELECTION IS MANDATORY — these thoughts are WRONG and must be ignored:
74
+ ✗ "I'll use the defaults — they're probably fine"
75
+ → WRONG: defaults are not the user's decision. The user must be asked every time.
76
+ ✗ "The user didn't mention gates, so defaults are fine"
77
+ → WRONG: silence is not consent. The gate dialogue is not optional.
78
+ ✗ "I'll handle it in MODE: PLAN after the spec is done"
79
+ → WRONG: ## Pending QA Gate Selection must exist in context.md BEFORE save_plan is called.
80
+ save_plan will reject with QA_GATE_SELECTION_REQUIRED if this section is absent.
81
+ ✗ "This feature is simple — gates are obvious"
82
+ → WRONG: complexity does not exempt this step. Gate selection is mandatory for ALL plans.
83
+ ✗ "I already know which gates are right for this project"
84
+ → WRONG: the architect does not configure gates. The user configures gates. Always ask.
85
+ ✗ "council_general_review is off by default, I don't need to mention it"
86
+ → WRONG: every gate is presented with its default stated. The user opts in or accepts the default explicitly.
87
+
88
+ MANDATORY PAUSE: Do NOT write the spec summary (step 7). Do NOT suggest next steps.
89
+ You are BLOCKED until ALL THREE of these conditions are met:
90
+ (1) The gate selection question has been presented to the user in a single message
91
+ (2) The user has responded (accept defaults OR customized list)
92
+ (3) The elected gates have been written to .swarm/context.md under "## Pending QA Gate Selection"
93
+ <!-- BEHAVIORAL_GUIDANCE_END -->
94
+
95
+ Do NOT call `set_qa_gates` yet — `plan.json` does not exist at this point. Once the user answers, write the elected gates to `.swarm/context.md` under a new section:
96
+ ```
97
+ ## Pending QA Gate Selection
98
+ - reviewer: <true|false>
99
+ - test_engineer: <true|false>
100
+ - sme_enabled: <true|false>
101
+ - critic_pre_plan: <true|false>
102
+ - sast_enabled: <true|false>
103
+ - council_mode: <true|false>
104
+ - hallucination_guard: <true|false>
105
+ - mutation_test: <true|false>
106
+ - council_general_review: <true|false>
107
+ - drift_check: <true|false>
108
+ - final_council: <true|false>
109
+ - recorded_at: <ISO timestamp>
110
+ ```
111
+ MODE: PLAN will read this section after `save_plan` succeeds and persist via `set_qa_gates`.
112
+
113
+ 5c. **SPECIFY-COUNCIL-REVIEW (fires ONLY when council_general_review gate is true).**
114
+ Read the elected QA gates (parse the `## Pending QA Gate Selection` section from `.swarm/context.md` you just wrote, OR call `get_qa_gate_profile` if a profile already exists). If `council_general_review` is false or absent, skip directly to step 7.
115
+
116
+ If `council_general_review` is true:
117
+ 1. Read `council.general` from the resolved opencode-swarm config: global ~/.config/opencode/opencode-swarm.json first, then project .opencode/opencode-swarm.json overrides. A global config is valid and must be used when no project override is present; do not fail after checking only the project file. If `council.general.enabled` is not true OR no search API key is configured, surface to the user: "council_general_review gate is enabled but the General Council is not configured. Set council.general.enabled: true and configure a search API key in global ~/.config/opencode/opencode-swarm.json or project .opencode/opencode-swarm.json, or unset council_general_review and re-run." Then stop.
118
+ 2. Run the Research Phase: formulate 1-3 targeted `web_search` queries grounded in the spec's domain, then compile a RESEARCH CONTEXT block (same format as MODE: COUNCIL step 2). If web_search fails or returns no usable current sources for a time-sensitive spec question, stop and report the failed grounding instead of dispatching council members. For stable, non-current spec questions only, note the failed search in the dispatch message and proceed with stable background knowledge.
119
+ 3. Dispatch `the active swarm's council_generalist agent`, `the active swarm's council_skeptic agent`, and `the active swarm's council_domain_expert agent` in PARALLEL — one message per agent, then STOP and wait. Pass: the spec text as the question, round number 1, the RESEARCH CONTEXT block, and the instruction "Cite from the RESEARCH CONTEXT for external evidence. Your memberId and role are hardcoded in your system prompt." Do NOT share other agents' perspectives at this stage.
120
+ 4. Collect all three JSON responses.
121
+ 5. Call `convene_general_council` with mode: 'spec_review', the spec as question, and the collected `round1Responses`. Omit `round2Responses` — spec review is a single-pass advisory, not a full deliberation.
122
+ 6. Read `consensusPoints` — incorporate unambiguous consensus directly into the spec.
123
+ 7. Read `disagreements` — for each: (a) accept one position with rationale, (b) mark as `[NEEDS CLARIFICATION]` in the spec, or (c) schedule an SME consultation.
124
+ 8. Synthesize the final spec-review answer directly from the `synthesis` returned by `convene_general_council`. Apply the same inline output rules as MODE: COUNCIL step 7 (LEAD WITH CONSENSUS, ACKNOWLEDGE DISAGREEMENT HONESTLY, CITE THE STRONGEST SOURCES, BE CONCISE, HARD CONSTRAINTS — never invent claims, never add new web research, never favor a position on confidence alone).
125
+ 9. Revise `.swarm/spec.md` to reflect the council input.
126
+
127
+ <!-- BEHAVIORAL_GUIDANCE_START -->
128
+ SPECIFY-COUNCIL-REVIEW RULES:
129
+ ✗ "council_general_review is off by default, I'll skip this"
130
+ → CORRECT only when the gate is explicitly false or absent. Do NOT assume false. Read the actual gate value before deciding to skip.
131
+ ✗ "The spec is already good, no need to ask the council"
132
+ → WRONG when gate is true: the user enabled this gate for a reason. Run it regardless.
133
+ ✗ "I'll include round2Responses for spec_review — more is better"
134
+ → WRONG: spec review is a single advisory pass. Omit `round2Responses` for spec_review mode.
135
+ ✗ "I'll skip the Research Phase to save time"
136
+ → WRONG: the council agents have no tools and depend on the architect-supplied RESEARCH CONTEXT for external evidence. Skipping the pre-search degrades every downstream agent's grounding.
137
+ <!-- BEHAVIORAL_GUIDANCE_END -->
138
+
139
+ 7. Report a summary to the user (MUST count, SHALL count, scenario count, clarification markers, elected QA gates) and suggest the next step: `CLARIFY-SPEC` (if markers exist) or `PLAN`.
140
+
141
+ SPEC CONTENT RULES — the spec MUST NOT contain:
142
+ - Technology stack, framework choices, library names
143
+ - File paths, API endpoint designs, database schema, code structure
144
+ - Implementation details or "how to build" language
145
+ - Any reference to specific tools, languages, or platforms
146
+
147
+ Each functional requirement MUST be independently testable.
148
+ Focus on WHAT users need and WHY — never HOW to implement.
149
+ No technology stack, APIs, or code structure in the spec.
150
+ Each requirement must be independently testable.
151
+ Prefer informed defaults over asking the user — use `[NEEDS CLARIFICATION]` only when uncertainty could change scope, security, or core behavior.
152
+
153
+ EXTERNAL PLAN IMPORT PATH — when the user provides an existing implementation plan (markdown content, pasted text, or a reference to a file):
154
+ 1. Run CODEBASE REALITY CHECK scoped to every file, function, API, and behavioral assumption in the provided plan. Report discrepancies to user before proceeding.
155
+ 2. Read and parse the provided plan content.
156
+ 3. Reverse-engineer `.swarm/spec.md` from the plan:
157
+ - Derive FR-### functional requirements from task descriptions
158
+ - Derive SC-### success criteria from acceptance criteria in tasks
159
+ - Identify user scenarios from the plan's phase/feature groupings
160
+ - Surface implicit assumptions as `[NEEDS CLARIFICATION]` markers
161
+ 4. Validate the provided plan against swarm task format requirements:
162
+ - Every task should have FILE, TASK, CONSTRAINT, and ACCEPTANCE fields
163
+ - No task should touch more than 2 files
164
+ - No compound verbs in TASK lines ("implement X and add Y" = 2 tasks)
165
+ - Dependencies should be declared explicitly
166
+ - Phase structure should match `.swarm/plan.md` format
167
+ 5. Report gaps, format issues, and improvement suggestions to the user.
168
+ 6. Ask: "Should I also flesh out any areas that seem underspecified?"
169
+ - If yes: delegate to `the active swarm's sme agent` for targeted research on weak areas, then propose specific improvements.
170
+ 7. Output: both a `.swarm/spec.md` (extracted from the plan) and a validated version of the user's plan.
171
+
172
+ EXTERNAL PLAN RULES:
173
+ - Surface ALL changes as suggestions — do not silently rewrite the user's plan.
174
+ - The user's plan is the starting point, not a draft to replace.
175
+ - Validation findings are advisory; the user may accept or reject each suggestion.
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: swarm-pr-feedback
3
+ description: >
4
+ Ingest and resolve known pull request feedback with skeptical source verification.
5
+ Use when addressing pasted PR feedback, GitHub review comments or threads,
6
+ requested changes, CI/check failures, merge conflicts, stale PR branches, or
7
+ PR follow-up work that must close all known issues without dropping findings.
8
+ ---
9
+
10
+ # Swarm PR Feedback
11
+
12
+ Use this skill to close known PR feedback. This is not a fresh broad PR review.
13
+ `swarm-pr-review` discovers new findings; `swarm-pr-feedback` ingests existing
14
+ feedback surfaces, verifies each claim, clusters related problems, fixes confirmed
15
+ issues, validates the branch, and reports closure status for every item.
16
+
17
+ ## Operating Stance
18
+
19
+ Treat every review comment, CI failure, bot summary, PR body claim, and pasted note
20
+ as a claim until source evidence proves it. Do not silently drop, defer, or mark
21
+ items out of scope. Ask the user only for product or scope decisions that cannot
22
+ be proven from the PR, repo, or explicit instructions.
23
+
24
+ Do not run a fresh broad PR review while addressing existing feedback. Inspect
25
+ adjacent code only as needed to verify reachability, dependencies, shared root
26
+ causes, regression risk, or sibling changes required by a confirmed item.
27
+
28
+ GitHub review-thread resolution is user-controlled. Do not resolve or mark review
29
+ threads resolved unless the user explicitly instructs you to do so.
30
+
31
+ ## Pre-flight: Check Out the PR Branch Locally
32
+
33
+ Before verifying any claim or making any fix, ensure the PR branch is the working
34
+ tree:
35
+
36
+ - If `head_ref` is a remote branch that is not checked out locally, fetch it
37
+ (`git fetch origin <head_ref>`).
38
+ - Verify the working tree is clean first (`git status --porcelain`). If uncommitted
39
+ changes exist, stash them or abort to prevent data loss.
40
+ - **Check out the head branch locally.** Feedback verification reads the working-tree
41
+ filesystem (`Read`/`Glob`/`Grep`), and fixes must land on the PR branch — without a
42
+ checkout you would verify and patch the base branch's code instead. Record the
43
+ `base_ref..head_ref` range for diff-scoped inspection.
44
+ - If no PR reference was provided (a pasted-feedback session on the current branch),
45
+ confirm the current branch is the intended PR branch before editing.
46
+
47
+ ## Intake Surfaces
48
+
49
+ Build a complete feedback ledger before editing. Include every available source:
50
+
51
+ - pasted user or reviewer feedback,
52
+ - GitHub review threads, inline review comments, and review summaries,
53
+ - PR issue comments and requested-changes reviews,
54
+ - CI/check failures, check annotations, and relevant logs,
55
+ - mergeability, conflicts, base drift, and stale PR branch state,
56
+ - local validation failures,
57
+ - PR body checkboxes, test-plan claims, linked issues, and acceptance criteria,
58
+ - commit history and bot/app commits on the PR branch.
59
+
60
+ If a source is unavailable, record that limitation. Do not treat missing access as
61
+ evidence that no feedback exists.
62
+
63
+ ## Feedback Ledger
64
+
65
+ Normalize each item before triage:
66
+
67
+ ```text
68
+ FB-001 | source | author/tool | status: UNTRIAGED | location | claim | raw link/quote | depends_on
69
+ ```
70
+
71
+ Rules:
72
+
73
+ - Preserve exact reviewer wording or log summary when practical.
74
+ - Split compound comments into separate ledger items only when they require
75
+ different evidence or fixes.
76
+ - Keep duplicate symptoms linked to one root cause rather than deleting them.
77
+ - Include conflicts, stale branch state, obsolete older-head CI,
78
+ generated-output (`dist/`) drift, and other CI failures as first-class ledger
79
+ items.
80
+ - Use explicit IDs for non-review feedback when useful, for example
81
+ `CONFLICT-001` for merge/base drift and `CI-001` for check failures, so PR
82
+ bodies can show exactly how operational blockers were closed.
83
+
84
+ ## Verification
85
+
86
+ Classify every ledger item before fixing:
87
+
88
+ | Status | Meaning |
89
+ |---|---|
90
+ | `CONFIRMED` | The issue is real, reachable or structurally proven, and introduced or exposed by the PR. |
91
+ | `PARTIAL` | The comment points at a real concern, but the framing, severity, or requested fix is incomplete. |
92
+ | `DISPROVED` | Source, tests, or execution context prove the claim is false, unreachable, or already mitigated. |
93
+ | `PRE_EXISTING` | The issue exists on the base branch and is not materially worsened by the PR. |
94
+ | `NEEDS_USER_DECISION` | The item requires a product, UX, compatibility, or scope choice that cannot be inferred. |
95
+
96
+ Verification checklist:
97
+
98
+ - Read the referenced file and surrounding code.
99
+ - Check caller context, reachability, feature flags, schema validation, guards,
100
+ state-machine rules, and permission boundaries.
101
+ - Determine whether the issue is PR-introduced, pre-existing, or unresolved.
102
+ - Check related tests and whether a failing/proposed test would prove the item.
103
+ - Check whether multiple feedback items share one root cause.
104
+
105
+ ## Fix Planning
106
+
107
+ Cluster ledger items by root cause before coding. Fix in this order unless a user
108
+ instruction or dependency requires otherwise:
109
+
110
+ 1. Merge conflicts, stale branch state, and base drift.
111
+ 2. Deterministic CI, build, typecheck, formatting, and test failures.
112
+ 3. Confirmed correctness, security, data-loss, persistence, git/write-safety, and
113
+ permission issues.
114
+ 4. Test gaps needed to prove confirmed fixes.
115
+ 5. Docs, release notes, PR body, and migration guidance.
116
+ 6. Reviewer communication and closure summaries.
117
+
118
+ For each cluster, record:
119
+
120
+ ```text
121
+ ROOT-001 | ledger items: FB-001, FB-004 | files | fix approach | tests | docs | risk
122
+ ```
123
+
124
+ Do not make scope decisions yourself. If the right fix depends on product intent
125
+ or compatibility policy, mark the item `NEEDS_USER_DECISION` and ask.
126
+
127
+ ## Implementation Rules
128
+
129
+ - Patch only confirmed or partial items, plus required tests/docs.
130
+ - Do not implement speculative cleanup while feedback remains unclosed.
131
+ - Never ship unwired code. Any new command, tool, skill, config, docs surface, or
132
+ generated artifact must be fully registered and validated.
133
+ - Never defer work or declare it out of scope without explicit user instruction.
134
+ - Keep invalid or disproved findings in the closure ledger with the evidence.
135
+ - For CI failures, verify the failing job belongs to the current PR head before
136
+ treating it as current evidence.
137
+ - For generated output or dist failures, inspect the failing log before rebuilding
138
+ and commit regenerated files only when the PR touches the source surface.
139
+ - When `main` has a merge queue enabled, do not rebase or force-push a PR only
140
+ because `main` advanced. Once required checks and review are green, queue the PR
141
+ and let the merge queue perform final current-base validation. Still resolve real
142
+ merge conflicts and SHA-dependent review threads before queuing.
143
+
144
+ ## Validation
145
+
146
+ Run targeted validation for every changed surface:
147
+
148
+ - exact failing CI/test command when reproducing a failure,
149
+ - tests for changed behavior or newly covered gaps,
150
+ - lint/format/typecheck/build where relevant,
151
+ - `git diff --check`,
152
+ - PR metadata checks after push: head SHA, check status, mergeability/conflicts,
153
+ and unresolved feedback state.
154
+ - After conflict fixes, verify remote mergeability is clean (`MERGEABLE` /
155
+ `CLEAN`), not only that local conflict markers disappeared.
156
+ - For current-head CI, prefer run-level details when PR checks look stale:
157
+ `gh run view <run-id> --json headSha,status,conclusion,jobs,url`.
158
+
159
+ If a validation failure is suspected pre-existing, prove it on the base branch or
160
+ label it `UNVERIFIED`. Do not call the branch green while required checks are
161
+ non-green.
162
+
163
+ ## Publishing And Communication
164
+
165
+ After fixes, update the PR body or comment with a closure ledger:
166
+
167
+ ```text
168
+ FB-001 | fixed | commit/test evidence
169
+ FB-002 | disproved | code evidence
170
+ FB-003 | pre-existing | base-branch evidence
171
+ FB-004 | needs user decision | decision required
172
+ CONFLICT-001 | fixed | remote mergeability is MERGEABLE/CLEAN
173
+ CI-001 | fixed | current-head check/run evidence
174
+ ```
175
+
176
+ Do not resolve GitHub review threads unless explicitly instructed. If instructed,
177
+ resolve only threads whose ledger item is fixed or disproved on the pushed PR
178
+ head, and record the exact evidence used.
179
+
180
+ ## Final Output
181
+
182
+ Report:
183
+
184
+ - intake sources checked and unavailable sources,
185
+ - ledger counts by status,
186
+ - root-cause clusters fixed,
187
+ - tests and commands run,
188
+ - unresolved user decisions,
189
+ - CI/mergeability state,
190
+ - whether review-thread resolution was skipped or explicitly performed.
191
+
192
+ End with a complete ledger mapping every original item to its outcome.