code-thermostack
Turn a thermonuclear code-quality review of the current Graphite stack into an approved local child fix stack. Use for Thermostack, thermo stack, thermonuclear follow-up stack, or turning harsh code-quality review findings into a Graphite stack.
- License 许可
- MIT
- 所属仓库
- nseng-ai/ns
- 最近更新
- 2026-10-02
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- code-thermostack
- description
- Turn a thermonuclear code-quality review of the current Graphite stack into an approved local child fix stack. Use for Thermostack, thermo stack, thermonuclear follow-up stack, or turning harsh code-quality review findings into a Graphite stack.
- disable-model-invocation
- true
02 资源文件 1
- 参考文档agents/openai.yaml43 B
03 SKILL.md 正文
Thermostack
Thermostack turns a thermonuclear maintainability review of the current Graphite stack changes into a local-only Graphite child stack of follow-up fixes. The original checked-out branch is the target/original change and remains untouched; Thermostack creates approved children above it.
Safety boundaries
- Require explicit user approval after the preview and before any branch, commit, or stack mutation.
<!-- SYNC: the remote-safety clause ("submit PRs, push, land, close GitHub state, or mutate remotes") travels verbatim to the implementation clause below and is attested in the Final report; edit all three sites together. -->
- Never submit PRs, push, land, close GitHub state, or mutate remotes.
- Never amend the original branch. Create local child branches above the current stack tip.
- Stop at the first non-confident implementation decision or validation failure. Preserve the completed clean prefix, leave state visible, and report the exact blocker and pending batches.
- Do not create or leave hidden WIP branches. Local-only deletion of an empty/no-code current branch is allowed when it is clearly safe; otherwise leave visible state and report the blocker.
- Keep persistence session-local. Thermostack itself does not store review plans in Branch Memory, reviews state, or other durable stores.
Subagent contract
Thermostack is parent-orchestrated: the main agent owns preflight, ranking, preview, Graphite and remote-safety decisions, branch creation, validation, commits, and final reporting. Subagents are narrow, and this section is the single authoritative statement of their rules. Every dispatch prompt must carry the role's clause below verbatim, and the parent must inspect every subagent result before validation and commit.
- Review clause — exactly one fresh review-only subagent collects findings. It edits nothing and returns structured findings only.
- Implementation clause — exactly one focused subagent per approved branch, dispatched serially: never run implementation subagents in parallel or use multiple worktrees for a single Thermostack run. The subagent may edit only the already-created current branch. It must not create or switch branches; commit or amend by any means (Graphite or raw git); submit PRs, push, land, close GitHub state, or mutate remotes; or touch durable stores. It must stop and report on ambiguity, unexpected files, or required scope expansion.
Capability and configuration:
- A harness supports editing subagents when it exposes a tool or adapter that can launch a focused subagent in the current repository/worktree with normal file-editing tools and return at least final text.
- Omit explicit model selection for implementation subagents unless the user or command supplies one.
- Inline fallback is licensed only when the harness genuinely lacks the capability — never as a convenience in a capable harness — and must carry the workflow step's degraded label.
1. Preflight
- Use the
code-graphiteskill for Graphite operations, stack mental model, and recovery guidance. - Confirm and record the current branch as the original-change target for this run. Keep this recorded
BASE_BRANCHfor every generated branch name, even after Thermostack checks out the first child branch:git branch --show-currentmust be a non-trunk branch.git status --shortmust be clean before review planning and again before mutation.
- Confirm the branch is Graphite-tracked with non-display plumbing such as
gt parent --no-interactiveorgt children --no-interactive, per the display-output rule indocs/conventions/graphite-dependency-boundary.md. - Determine and record
STACK_BASE_REF, the base of the current Graphite stack, before dispatching the reviewer. This is the default review base. Runns slot gt exec stack-branches --downstack --format json:brancheslists the downstack branches bottom-to-top ending at the current branch, andSTACK_BASE_REFis theparentof the firstedgesentry — the parent of the bottom-most stack branch, equal to thetrunkfield when the stack sits directly on trunk. If the command fails or the stack base is otherwise ambiguous, stop and ask rather than reviewing the wrong diff. - Sanity-check the review scope with
git diff --stat "$STACK_BASE_REF"...HEADandgit diff --name-only "$STACK_BASE_REF"...HEAD. The diff must reflect the intended stack changes. Never compare$BASE_BRANCH...HEADwhenBASE_BRANCHis the checked-out branch; that produces an empty review. - Check for existing generated branches for this base. Stop if branches matching
$BASE_BRANCH/thermo-*already exist unless the user explicitly chooses a recovery path. - Confirm the thermonuclear Reviews review definition is readable at
.ns/reviews/thermonuclear-review/review.md. This review definition is the authoritative thermonuclear review content for Thermostack; thereview-thermonuclear-reviewskill is only a thin invoke-only wrapper around it.
2. Collect thermonuclear findings
Dispatch the review subagent under the Subagent contract — its review clause travels verbatim in the prompt, along with these requirements:
Review the current stack changes only: use the diff from recorded stack base `STACK_BASE_REF` to current `HEAD` (`STACK_BASE_REF...HEAD`). Do not compare the checked-out branch name `BASE_BRANCH` to `HEAD`; that is the target branch and may equal `HEAD`. Explicitly load/read `.ns/reviews/thermonuclear-review/review.md`, then perform that thermonuclear maintainability review against the stack diff.
For each finding include:
- id
- title
- files/areas
- evidence
- problem
- proposed fix
- behavior-risk notes
- dependency notes
- confidence/risk notes
- validation hints
Prioritize structural regressions, missed code-judo simplifications, spaghetti/branching growth, boundary/type-contract issues, file-size/decomposition, modularity, and maintainability. Include high-risk/high-reward findings too; do not omit speculative but plausible improvements.
If the harness genuinely has no subagent capability, run the review inline after reading .ns/reviews/thermonuclear-review/review.md and label the resulting proposal as degraded confidence: inline review, no fresh subagent.
If the reviewer returns vague prose instead of structured findings, restructure it into the fields above before ranking. Do not proceed from ambiguous bullets.
3. Rank and batch
Rank findings by merge-likelihood / trunk confidence, not by theoretical upside. Use exactly these confidence buckets:
trunk-likely— low behavioral risk, small blast radius, clear evidence, obvious reviewer acceptability, little dependency uncertainty.likely— plausible and bounded, but with some implementation or review uncertainty.uncertain— useful but meaningfully dependent on interpretation, tradeoffs, or broader context.speculative— high-risk/high-reward, broad, preference-heavy, or likely to need maintainer discussion.
Include every finding in the ordered proposal. Speculative work usually sorts later, but a hard dependency may force an earlier lower-confidence batch. Call every such risk-order inversion out explicitly.
Batch one independently reviewable fix per branch. Combine findings only when they share a root cause, invariant, implementation seam, or hard dependency. Each batch should be reviewable and revertible as its own local child branch.
Branch names must use the recorded original BASE_BRANCH as <base> and a lowercase kebab slug for <batch>:
<base>/thermo-<NN>-<batch>
Use two-digit ordering (01, 02, ...). Keep slugs short and collision-safe.
4. Preview gate
Before any mutation, present an ordered stack proposal and require explicit approval. For each proposed batch include:
- branch name;
- confidence bucket;
- included finding ids;
- rationale for the rank;
- files/areas expected to change;
- dependencies;
- dependency/risk-order inversions and why they are required;
- validation hints.
Also summarize findings that are included later in the stack so the user can see the speculative tail. If the user changes scope, selected findings, ordering, or batching, regenerate the preview before asking for approval again.
Approval must be explicit, such as "approve Thermostack plan" or "create these branches." If approval is absent or ambiguous, do not mutate.
5. Implement one reviewable branch at a time
After approval, implement approved batches in order. The parent owns branch creation, subagent prompting, diff review, validation, Graphite amend, and clean-status checks.
For each batch:
-
Recheck
git status --shortis clean. -
Create the empty child branch from the current stack tip before editing:
gt create <branch-name> -m "thermo: <batch>"If
gt createbehavior appears different from creating an empty branch on a clean worktree, re-checkgt create --helpand stop rather than improvising. -
If the harness supports editing subagents, dispatch this branch's implementation subagent under the Subagent contract. The prompt must include:
- current branch name;
- approved finding ids;
- intended files/areas;
- behavior-risk notes;
- validation hints;
- the implementation clause, verbatim, as hard constraints.
-
If the harness lacks editing-subagent support, implement only the approved batch inline and label the branch in the final report as
degraded: inline implementation, no editing subagent. -
Inspect the implementation result before continuing. If the harness returns machine status or session metadata, any non-final status is a stop condition until inspected. If the harness returns only final text, manually inspect the resulting diff before treating the branch as implemented.
-
Review the diff for scope before validation. Unexpected files, scope expansion, or failed local validation is a stop condition.
-
Run targeted validation: run every validation hint recorded for the batch, plus the narrowest scoped project check for each file type the batch touched (in this repo, pick it from
docs/conventions/just-gate-map.md). Validation is complete when each of those commands has run green; broader checks are not required. -
Stage changes and amend the branch:
gt modify -m "thermo: <batch>" -
Confirm
git status --shortis clean before continuing to the next batch.
Ambiguous implementation, validation failure after reasonable local attempts, an ambiguous dirty subagent diff, or a fix requiring scope outside the approved batch are all stop conditions: apply the Safety boundaries stop rule.
6. Final report
Report:
- review collection subagent evidence, or the degraded inline-review label if no review subagent was available;
- created local branches in order;
- for each branch, confidence bucket and rationale;
- for each branch, whether implementation was delegated to a subagent or used inline fallback, plus final status and validation summary;
- commands run and validations performed;
- skipped or pending findings;
- dependency/risk-order inversions;
- any recovery action taken;
- an explicit statement that no PRs were submitted, nothing was pushed, no remotes were mutated, and the original branch was not amended.
04 同仓库更多 Skills
pr-make-accountable
Interview a PR author to establish shared understanding of intent and design decisions, then co-author the What / Why / Changes PR body with opt-in Requested reviewer focus.
typescript-style
Opinionated style guide for strict, portable TypeScript. Use when writing, designing, or reviewing TypeScript: type design, boundary validation, error handling, module architecture, and review discipline.
typescript-fake-driven-testing
TypeScript fake-driven testing architecture. Use when writing or reviewing TS code with external dependencies, gateway interfaces, real adapters, in-memory fakes, or CLI scenario tests.
ns-typescript
TypeScript overlay for ns-style projects. Use when editing or reviewing TS in this repo: tsconfig baseline, pnpm/Vitest/oxlint/oxfmt/native tsc commands, relative .ts imports, workspace subpath exports, and the exactOptionalPropertyTypes spread idiom. Repo-specific enforcement (test lanes, time seams, style guard) lives in the host repo's AGENTS.md.
ns-typescript-style-tripwire
Invoke the ns TypeScript style Tripwire against a supplied diff or current branch.
skill-management
Manage skills with `npx skills`: add, edit, remove, rename, update, or list skills (local or GitHub), and the nested `skills/<disposition>/.../<name>/` / flat `.agents/skills/` layout conventions.