Preflight
Use this skill after a change is functionally correct and before commit or
handoff. The PR, commit text, task notes, and final response should describe
already-preflighted code.
Goals
Leave the smallest clear diff that still solves the issue. Run focused
review passes instead of one subjective read. Preserve behavior while
improving readability, correctness, and alignment with repo rules.
Scale the review to the change size
Pick an effort level from the diff before reading anything else:
git diff --stat
git status --short
Include untracked new files from git status --short (or
git ls-files --others --exclude-standard) when choosing the scale. A split
into new files can look deceptively small in git diff --stat until those
files are staged.
| Change size |
Required context |
Review passes |
Compliance note |
| XS (docs/skill/config only, ≤2 files) |
Root AGENTS.md if relevant |
One combined pass |
One line |
| S (single module, ≤~50 LOC, no public API) |
Root AGENTS.md, nearest nested AGENTS.md |
One combined pass |
One line |
| M (multi-file, ≤~200 LOC, no cross-module) |
+ active task file, ExecPlan if one exists |
Pass 1 + Pass 2 |
Short block |
| L/XL (cross-module, public API, agent loop, persistence, concurrency, external integrations, security boundaries) |
+ design docs and ADRs in the changed area |
All three passes |
Full block |
Only read context items that are relevant to the changed surface. Discover
them with targeted commands, e.g. rg --files -g AGENTS.md,
rg --files docs/design-docs docs/adr, git diff -- <paths>.
Required context items, in priority order:
- repo root
AGENTS.md
- nested
AGENTS.md files for the changed areas
ahm context task, ahm task show <id> output when the work came from a
task; open the active task file only when ahm is unavailable or when
reviewing manual edits to the task file itself; use
.agents/.tasks/index.md only as a fallback queue artifact when ahm is
unavailable
- the relevant active exec plan when one exists for the current work
(see
.agents/exec-plans/active/)
ahm context plan and docs/design-docs/index.md for L/XL changes
- any design doc or ADR directly relevant to the changed area
- the changed files and enough nearby context to review them
Review passes
Treat each pass as a clean read with its own focus. Do not blur findings
across passes.
Pass 1: Rules and documentation conformance
- Are we following
AGENTS.md, nested AGENTS.md, and design docs?
- Did we drift from documented repo patterns or ownership boundaries?
- If the changed surface is user-visible CLI/API/config/file-format/workflow
behavior, did we update the affected docs in the same change or record why
the behavior is intentionally undocumented?
- If the work came from a task or ExecPlan, does the implementation match
its acceptance notes and recorded decisions?
- Did we update task, ExecPlan, design doc, or ADR notes when the change
discovered something durable?
Pass 2: Correctness and source of truth
This pass is about project-native correctness at the changed surface.
Before reviewing, infer the project's language, framework, runtime, data
modeling style, and validation tools from the changed files plus nearby
manifests and scripts. Prefer explicit repo instructions in AGENTS.md,
package manifests, lockfiles, CI config, Makefile, justfile, and
existing tests over generic language advice.
Focus questions:
- Are we preserving canonical domain models, schemas, identifiers, and
state machines, or did we stringify, parse, duplicate, or reshape data
instead of carrying the project-owned representation?
- Did we introduce stringly typed sentinels, unvalidated dictionaries/maps,
loosely shaped JSON, global state, or duplicated constants where the
project normally uses a schema, class, struct, enum, type alias, database
constraint, or shared config?
- Are fallible boundaries explicit about failure, with useful context and
without swallowing parse, validation, network, filesystem, process,
persistence, auth, or external-service errors?
- Are concurrency, async, transaction, lifecycle, and resource boundaries
consistent with nearby code and the runtime in use?
- Are CLI/API/UI/database/config/external-integration boundaries validated
at the edge and then represented with project-owned shapes downstream?
- Could an existing compiler, type checker, linter, schema validator,
migration check, test helper, or narrower data model catch a mistake
earlier than this implementation currently does?
Pass 3: Overengineering and simplification
- Did we write more code than needed?
- Did we create helpers, abstractions, factories, wrappers, or indirection
without enough payoff?
- Could the same result be expressed more directly?
- Are new modules, traits, builders, or generic helpers justified by real
reuse or by an existing design boundary?
Between-pass hygiene
Ground each pass in narrow local evidence. Use the smallest check that fits
the change:
git diff --stat and git diff -- <paths> to keep review anchored
- formatters when formatting is affected, chosen from repo tooling
(
gofmt, prettier, ruff format, language-native formatters, or a
documented script)
- focused tests in the changed area using the repo's normal runner
(
go test, pytest, npm test, cargo test, bundle exec, make,
just, or the relevant framework command)
- type checks, linters, schema checks, migrations, generated-code checks, or
build steps when public types, shared code, config, API contracts, database
shape, or dependency behavior changed
- the repo's final validation command after code/config/dependency changes
are complete, when one is documented in
AGENTS.md, CI config, Makefile,
justfile, package scripts, or project docs
For docs-only or skill-only edits, verify rendered Markdown and links by
inspection or rg --files; full CI is not required.
Synthesis
After running the passes for the chosen scale, synthesize into one balanced
report with these headings:
- "How did we do?"
- "Feedback to keep"
- "Feedback to ignore"
- "Plan of attack"
- "Preflight compliance" (skip for XS; one line for S; short block for M;
full block for L/XL — see template below)
What to fix automatically
In an unattended implementation flow, apply worthwhile feedback before
commit. Prioritize:
- type drift, unnecessary cloning/string conversion, duplicated type defs
- violations of documented repo boundaries or design documents
- dead helpers, dead code, debug leftovers, placeholder text
- new panic/abort paths, placeholder exceptions, debug prints, commented-out
code, broad lint suppressions, or ignored errors in production paths
- errors lacking actionable context at CLI/API/UI/database/config/process/
network/external-service boundaries
- unnecessary wrappers or indirection removable locally without widening
scope
Leave out feedback that is speculative, conflicts across passes, or would
widen scope materially. Mention it briefly in the synthesis.
Compliance note
Make the chosen context auditable. Length scales with change size.
XS / S example:
### Preflight compliance
- XS docs-only change to one skill file. Root AGENTS.md skim only; no
nested AGENTS.md under the changed path; no CI required.
M / L / XL template:
### Preflight compliance
- Root AGENTS.md: read
- Nested AGENTS.md: <paths or "none under changed paths">
- Task context: <task id> / not applicable because <reason>
- ExecPlan: <plan id> / not applicable because <reason>
- Design docs: <docs> / not applicable because <reason>
- ADRs: <adrs> / not applicable because <reason>
- Documentation impact: <docs checked/updated, or intentionally none because ...>
- Changed files and diff: reviewed via `git diff --stat` and targeted diffs
- Validation: <commands run>
Do not write blanket "no design docs to check" claims unless you actually
looked for a relevant one and can explain why the changed area has no
design-doc surface.
Steps
- Run
git diff --stat and git status --short. Pick a scale from the
table, counting untracked new files.
- Read only the required-context items for that scale.
- Run the review passes for that scale, with a narrow evidence check
between them.
- Synthesize findings into the balanced report.
- Apply worthwhile feedback that is clearly in scope.
- Rerun the narrowest affected validation, then the repo's documented
final validation command when the finished work changed code, config, or
dependencies.
- Update task notes, ExecPlan notes, commit text, and PR/final response to
describe the post-preflight state.
Stop rules
- Do not turn this into a refactor unrelated to the ticket.
- Do not churn stable code outside the changed area just to make it
prettier.
- If a cleanup is subjective and not clearly better, leave it alone.
- Do not blindly apply every finding from every pass.
- Do not run broad or slow checks repeatedly when a focused test already
covers the current pass; save the repo's broad validation command for
final validation.
- Do not escalate the scale beyond what the diff justifies just to feel
thorough.
1---2name: preflight3description: Run a focused review-readiness pass on a nearly finished change before commit. Scales the review to change size (XS/S = one pass, M = two passes, L/XL = three sequential passes covering rules conformance, correctness/source-of-truth, and overengineering). Then synthesize and apply the worthwhile fixes.4---56# Preflight78Use this skill after a change is functionally correct and before commit or9handoff. The PR, commit text, task notes, and final response should describe10already-preflighted code.1112## Goals1314Leave the smallest clear diff that still solves the issue. Run focused15review passes instead of one subjective read. Preserve behavior while16improving readability, correctness, and alignment with repo rules.1718## Scale the review to the change size1920Pick an effort level from the diff before reading anything else:2122```bash23git diff --stat24git status --short25```2627Include untracked new files from `git status --short` (or28`git ls-files --others --exclude-standard`) when choosing the scale. A split29into new files can look deceptively small in `git diff --stat` until those30files are staged.3132| Change size | Required context | Review passes | Compliance note |33| ----------------------------------------------- | -------------------------- | -------------------- | --------------- |34| **XS** (docs/skill/config only, ≤2 files) | Root AGENTS.md if relevant | One combined pass | One line |35| **S** (single module, ≤~50 LOC, no public API) | Root AGENTS.md, nearest nested AGENTS.md | One combined pass | One line |36| **M** (multi-file, ≤~200 LOC, no cross-module) | + active task file, ExecPlan if one exists | Pass 1 + Pass 2 | Short block |37| **L/XL** (cross-module, public API, agent loop, persistence, concurrency, external integrations, security boundaries) | + design docs and ADRs in the changed area | All three passes | Full block |3839Only read context items that are relevant to the changed surface. Discover40them with targeted commands, e.g. `rg --files -g AGENTS.md`,41`rg --files docs/design-docs docs/adr`, `git diff -- <paths>`.4243Required context items, in priority order:4445- repo root `AGENTS.md`46- nested `AGENTS.md` files for the changed areas47- `ahm context task`, `ahm task show <id>` output when the work came from a48 task; open the active task file only when `ahm` is unavailable or when49 reviewing manual edits to the task file itself; use50 `.agents/.tasks/index.md` only as a fallback queue artifact when `ahm` is51 unavailable52- the relevant active exec plan when one exists for the current work53 (see `.agents/exec-plans/active/`)54- `ahm context plan` and `docs/design-docs/index.md` for L/XL changes55- any design doc or ADR directly relevant to the changed area56- the changed files and enough nearby context to review them5758## Review passes5960Treat each pass as a clean read with its own focus. Do not blur findings61across passes.6263### Pass 1: Rules and documentation conformance6465- Are we following `AGENTS.md`, nested `AGENTS.md`, and design docs?66- Did we drift from documented repo patterns or ownership boundaries?67- If the changed surface is user-visible CLI/API/config/file-format/workflow68 behavior, did we update the affected docs in the same change or record why69 the behavior is intentionally undocumented?70- If the work came from a task or ExecPlan, does the implementation match71 its acceptance notes and recorded decisions?72- Did we update task, ExecPlan, design doc, or ADR notes when the change73 discovered something durable?7475### Pass 2: Correctness and source of truth7677This pass is about project-native correctness at the changed surface.78Before reviewing, infer the project's language, framework, runtime, data79modeling style, and validation tools from the changed files plus nearby80manifests and scripts. Prefer explicit repo instructions in `AGENTS.md`,81package manifests, lockfiles, CI config, `Makefile`, `justfile`, and82existing tests over generic language advice.8384Focus questions:8586- Are we preserving canonical domain models, schemas, identifiers, and87 state machines, or did we stringify, parse, duplicate, or reshape data88 instead of carrying the project-owned representation?89- Did we introduce stringly typed sentinels, unvalidated dictionaries/maps,90 loosely shaped JSON, global state, or duplicated constants where the91 project normally uses a schema, class, struct, enum, type alias, database92 constraint, or shared config?93- Are fallible boundaries explicit about failure, with useful context and94 without swallowing parse, validation, network, filesystem, process,95 persistence, auth, or external-service errors?96- Are concurrency, async, transaction, lifecycle, and resource boundaries97 consistent with nearby code and the runtime in use?98- Are CLI/API/UI/database/config/external-integration boundaries validated99 at the edge and then represented with project-owned shapes downstream?100- Could an existing compiler, type checker, linter, schema validator,101 migration check, test helper, or narrower data model catch a mistake102 earlier than this implementation currently does?103104### Pass 3: Overengineering and simplification105106- Did we write more code than needed?107- Did we create helpers, abstractions, factories, wrappers, or indirection108 without enough payoff?109- Could the same result be expressed more directly?110- Are new modules, traits, builders, or generic helpers justified by real111 reuse or by an existing design boundary?112113## Between-pass hygiene114115Ground each pass in narrow local evidence. Use the smallest check that fits116the change:117118- `git diff --stat` and `git diff -- <paths>` to keep review anchored119- formatters when formatting is affected, chosen from repo tooling120 (`gofmt`, `prettier`, `ruff format`, language-native formatters, or a121 documented script)122- focused tests in the changed area using the repo's normal runner123 (`go test`, `pytest`, `npm test`, `cargo test`, `bundle exec`, `make`,124 `just`, or the relevant framework command)125- type checks, linters, schema checks, migrations, generated-code checks, or126 build steps when public types, shared code, config, API contracts, database127 shape, or dependency behavior changed128- the repo's final validation command after code/config/dependency changes129 are complete, when one is documented in `AGENTS.md`, CI config, `Makefile`,130 `justfile`, package scripts, or project docs131132For docs-only or skill-only edits, verify rendered Markdown and links by133inspection or `rg --files`; full CI is not required.134135## Synthesis136137After running the passes for the chosen scale, synthesize into one balanced138report with these headings:139140- "How did we do?"141- "Feedback to keep"142- "Feedback to ignore"143- "Plan of attack"144- "Preflight compliance" (skip for XS; one line for S; short block for M;145 full block for L/XL — see template below)146147## What to fix automatically148149In an unattended implementation flow, apply worthwhile feedback before150commit. Prioritize:151152- type drift, unnecessary cloning/string conversion, duplicated type defs153- violations of documented repo boundaries or design documents154- dead helpers, dead code, debug leftovers, placeholder text155- new panic/abort paths, placeholder exceptions, debug prints, commented-out156 code, broad lint suppressions, or ignored errors in production paths157- errors lacking actionable context at CLI/API/UI/database/config/process/158 network/external-service boundaries159- unnecessary wrappers or indirection removable locally without widening160 scope161162Leave out feedback that is speculative, conflicts across passes, or would163widen scope materially. Mention it briefly in the synthesis.164165## Compliance note166167Make the chosen context auditable. Length scales with change size.168169**XS / S example:**170171```markdown172### Preflight compliance173- XS docs-only change to one skill file. Root AGENTS.md skim only; no174 nested AGENTS.md under the changed path; no CI required.175```176177**M / L / XL template:**178179```markdown180### Preflight compliance181182- Root AGENTS.md: read183- Nested AGENTS.md: <paths or "none under changed paths">184- Task context: <task id> / not applicable because <reason>185- ExecPlan: <plan id> / not applicable because <reason>186- Design docs: <docs> / not applicable because <reason>187- ADRs: <adrs> / not applicable because <reason>188- Documentation impact: <docs checked/updated, or intentionally none because ...>189- Changed files and diff: reviewed via `git diff --stat` and targeted diffs190- Validation: <commands run>191```192193Do not write blanket "no design docs to check" claims unless you actually194looked for a relevant one and can explain why the changed area has no195design-doc surface.196197## Steps1981991. Run `git diff --stat` and `git status --short`. Pick a scale from the200 table, counting untracked new files.2012. Read only the required-context items for that scale.2023. Run the review passes for that scale, with a narrow evidence check203 between them.2044. Synthesize findings into the balanced report.2055. Apply worthwhile feedback that is clearly in scope.2066. Rerun the narrowest affected validation, then the repo's documented207 final validation command when the finished work changed code, config, or208 dependencies.2097. Update task notes, ExecPlan notes, commit text, and PR/final response to210 describe the post-preflight state.211212## Stop rules213214- Do not turn this into a refactor unrelated to the ticket.215- Do not churn stable code outside the changed area just to make it216 prettier.217- If a cleanup is subjective and not clearly better, leave it alone.218- Do not blindly apply every finding from every pass.219- Do not run broad or slow checks repeatedly when a focused test already220 covers the current pass; save the repo's broad validation command for221 final validation.222- Do not escalate the scale beyond what the diff justifies just to feel223 thorough.