Implement plan audited

From hawkyre/hawk-skills · View interactive version

Implement plan audited is an AI agent skill from the GitHub repository hawkyre/hawk-skills. Execute an approved plan with independent audits at risk and integration boundaries. Supports manual review or automatic execution. Inherits implement-plan verification and records progress outside the plan. Use when the user asks for audited implementation, not planning or a one-time code audit.

How to use this skill

Skill file

Implement plan (audited)

Same execution shape as implement-plan, with one addition: at strategic audit checkpoints (not after every increment), the audit-* specialist subagents run in parallel against the cumulative diff since the previous checkpoint and either auto-apply their fixes (auto mode) or surface them for user review (manual mode). The specialist subset is decided per checkpoint by audit-triage.

Choose checkpoints before execution and record them in state.json. Keep audit notes in worklog.md.

Specialists read the diff and their brief, without the plan or the user's goal.

Read the installed code-audit skill for orchestration. The native audit agent definitions contain the specialist briefs.

This skill inherits the entire per-increment verification loop from implement-plan Step 3, and the commit cadence contract CC-1 from implement-plan Step 3.5. It does not redefine them.

Args

Process

Step 1 — Bootstrap context

Delegates to implement-plan Step 1 (plan file, global standards, common-mistakes index, project check command, current git ref).

Additions:

Big-output discipline applies throughout: redirect heavy command output to /tmp/hawk-implement-plan-audited-<step>.log, inspect with rg -n 'error|warning|fail|FAIL' /tmp/hawk-implement-plan-audited-<step>.log | head -50. <step> is e.g. inc3-check, ckpt2-check, final-check.

Step 1.5 — Record audit checkpoints

Use the work units, ids, and dependency graph from implement-plan.

Read its references/execution-state.md for state updates and resume rules.

Honor existing checkpoint choices in state or older **Audit checkpoint:** yes plan fields.

Import older markers into state without editing the plan.

When no cadence exists, place checkpoints at meaningful risk or integration boundaries.

Examples include a changed authorization boundary, a migration stage, or a complete external integration.

Group routine work between those boundaries. Audit the final executable unit so no completed work remains unaudited.

Do not assign checkpoints to blocked units. A small plan has one unit and one final audit.

No size score is required.

Set state.json.increments[<id>].auditCheckpoint = true under the state lock.

Set auditStatus to pending for a new checkpoint. Preserve recorded audit completion on resume.

For older records, accept completion only when the worklog contains the completed audit and its range.

Preserve these fields when recording implementation outcomes.

Summarize where audits will run. Keep the plan unchanged.

Step 2 — Execution loop

For each increment in dependency order:

Before new implementation, run any pending checkpoint whose unit is already done.

Do not repeat its application work. Audit completion is separate from implementation completion.

  1. Read forwarded markers in state.json.increments[<id>].planOverride. Read the referenced audit note before choosing the implementation approach.
  1. Implement. Run implement-plan Step 3 in full (substeps 3.1–3.10, including the done-criteria check, the file-divergence check, and the structured outcome record). The per-increment commit fires via CC-1 (implement-plan Step 3.5).
  1. Checkpoint gate. If this unit has auditCheckpoint: true and auditStatus: pending in state:
  1. Mode gate.

Manual / user-driven increments are marked blocked-on-user and skipped, regardless of mode.

Step 3 — Launch the audit specialists

At a checkpoint, capture the cumulative diff per-file. Per-file enumeration first, then per-file capture — never the raw concatenated cumulative diff:

git diff --name-only <prev_checkpoint_ref>..HEAD > /tmp/hawk-implement-plan-audited-files-<ckpt>.log
# for each file in that list:
git diff <prev_checkpoint_ref>..HEAD -- <path> > /tmp/hawk-implement-plan-audited-diff-<ckpt>-<file-slug>.patch 2>&1

Specialist user prompts receive narrowed rg -n slices from the per-file captures, never the full cumulative diff.

Per-checkpoint triage

Before fan-out, call:

reviewer: audit-triage; brief: <scope, signals>

The triage agent contract (decision rule, output schema) is owned by agents/audit-triage.md and reused here without modification.

The orchestrator-side triage call — what fields to assemble in the user prompt — is mostly shared with code-audit/SKILL.md Step 2, with explicit deltas because the two skills capture diffs differently. The delegation table is the single source of truth:

| Field | Source |

| ----- | ------ |

| Changed files | Supersedes code-audit Step 2. This skill uses git diff --name-only <prev_checkpoint_ref>..HEAD (from the per-file capture flow), not git diff --name-only --stat <range>. |

| Risk-signal greps | Same as code-audit Step 2: narrowed rg -n over the diff captures, omit signals with no matches. Aggregation: greps run per-file; aggregate matches across all per-file captures into a single combined set, then apply the ~30-line cap to the combined set (not per file). |

| Scope stats | Same as code-audit Step 2 (files: N, lines added/removed: +A/-B, layers spanned: …) plus an additional field: increments covered: <N> increments (count, not the index range). |

| Adaptive bias | Delta: pass the specialist findings ledger from Step 1's run state. The triage agent may use this as a tiebreak: specialists with ≥2 prior findings this run get included automatically; specialists with 0 findings across ≥3 prior checkpoints may be safely skipped when other signals don't argue for them. |

| Parse contract | Same: tier: / specialists: / reason: lines, in that order. |

| Parse-fail fallback | Same: tier=standard, continue, never silently skip the audit. Auto mode does not stop on a malformed triage — bias is up. |

| When forced | Same: tier=light\|standard\|deep skips triage and uses the static mapping in code-audit/SKILL.md. |

| When run | Delta: per checkpoint, not once per skill invocation. Different checkpoints in the same run can legitimately land on different tiers. |

If code-audit Step 2 changes any "Same" row, this skill inherits the change automatically; the "Supersedes" and "Delta" rows are this skill's responsibility.

Triage decision is internal; record it in the structured audit note (Step 4).

Fan out the specialists in parallel

Start one independent reviewer per role in the selected subset. Use concrete agent names so install-time prefix rewriting stays consistent:

reviewer: audit-logic; brief: <USER PROMPT>
reviewer: audit-security; brief: <USER PROMPT>
reviewer: audit-simplification; brief: <USER PROMPT>
reviewer: audit-research; brief: <USER PROMPT>
reviewer: audit-architecture; brief: <USER PROMPT>

Skip any role not in the triage subset.

Do not delegate to code-audit; it is a skill, not an agent. Run the audit-* specialists directly from the main session.

Specialist user prompt — minimum-context principle

The agent body owns the role, anti-bias contract, verification rule, and output schema. The orchestrator's per-call user prompt contains only what specialists need to evaluate the code on its own merits:

## Files / diff in scope

{narrowed `rg -n` slices from the per-file captures}

## Standards (pasted inline, do not fetch)

{full content of every relevant `.agents/standards/` file}

## Common mistakes (pasted inline, do not fetch)

{full content of every relevant `.agents/common-mistakes/` file}

## Scope

This diff covers {N} increments — {files} files, +{added}/-{removed} lines, layers: {layers}. Do NOT look up which increments those are or what they did. Scale your reasoning to the diff size, nothing more.

## Verification clause requirement

For every FIX you propose, include a `verify:` clause — a concrete check that confirms your fix actually resolves the finding (a command to run, a test to add, an assertion to make, a query to evaluate). FIXes without a verify clause will be rejected at reconcile.

No increment indices in the prompt — scope stats only. The orchestrator keeps the index mapping internally for its own reconciliation; the specialist doesn't need it. Removes the bias risk where "Inc 1–3" might imply foundation work and bias the specialist toward foundational concerns.

Step 4 — Reconcile

When all specialists return:

  1. Merge their FIX / NOTE / QUESTION outputs the same way code-audit merges them — dedupe by path:line, attach overlapping reasoning, surface QUESTIONs immediately.
  1. Validate verify clauses. For each FIX in the merged set, confirm a verify: clause is present and the clause is runnable (a command, a test name, a specific assertion — not "ensure correctness"). FIXes missing or with non-runnable verify clauses are returned to the specialist if there's session budget, or escalated to the user.
  1. Apply, depending on mode:
  1. Plan-override flagging. If the merged output reveals that the approach taken in any covered increment was structurally wrong (a specialist's Why: describes a fundamentally cleaner architecture, or a fix touches the public API the plan specified):

Step 2 reads this marker before implementing the affected unit.

  1. Behavior-preservation FIXes. Any FIX that changes external behavior (HTTP response shape, function signature, side effects, error semantics, persisted data):
  1. Update the specialist findings ledger (in-memory from Step 1) with this checkpoint's per-specialist counts. The next checkpoint's triage sees this.
  1. Append the structured audit note to worklog.md under the checkpoint unit id:
**Audit checkpoint:** yes (executed)
audit-ckpt<N>: tier=<light|standard|deep> specialists=[<list>] reason="<from triage>"
  fixes=<count> notes=<count> plan-overrides=<count> behavior-changes=<count> covers=<inc-labels>

Three lines, structured fields, parseable. A reviewer reconstructing the run can read it in 5 seconds; a tool can parse it for run analytics.

The audit note is distinct from the per-increment outcome record owned by implement-plan Step 3.10 — different artifacts, different owners. Do not merge or duplicate them.

Because a checkpoint covers multiple increments, the merged FIX list will often be larger than a per-increment audit. Group findings by file in the user-facing report (manual mode) so reviewers can scan quickly.

Step 5 — Commit hygiene (delta over CC-1)

The contract is implement-plan CC-1 (Step 3.5). Per-increment commits delegate to it in full — branch detection, opt-out flow, stop-out edge cases, staging-by-discovery, rename/deletion handling, no-AI-attribution rule, pre-commit hook failure handling, empty-change skip. The additions here are separate audit-fix commits and a BEHAVIOR_CHANGE.md commit when applicable.

Cadence.

Ordering when the increment IS the checkpoint. The increment commit fires first (inside CC-1), then the checkpoint audit runs against the new HEAD, then any audit-fix commit fires after reconcile. git diff --name-only HEAD for audit-fix staging therefore sees only the audit's changes, not the increment's — because the increment was already committed.

Commit message style — discovery-driven, with audit-commit disambiguation. Read git log -10 --oneline to detect the dominant style (done once per run, by CC-1). Mirror it verbatim for increment commits. For audit commits, keep them peelable with git revert — match the detected style, checking Conventional Commits first because its <type>(<scope>): pattern overlaps the plain-scope pattern:

  1. Conventional Commits (messages match <type>(<scope>):) → chore({slug}): audit cleanup for {increment-labels} (e.g. chore(billing): audit cleanup for Inc 5–7).
  2. Plain <scope>: <description> (no parentheses) → audit: cleanup for {increment-labels}.
  3. Plain lowercase imperative, no prefix → prefix with audit: literally.
  4. Mixed / emoji-prefixed / JIRA-prefixed / unclear → default to plain audit: cleanup for {increment-labels}.

{slug} = the plan directory name (last component of .plans/<slug>/). {increment-labels} match the plan's increment labels — Inc 5–7 for a numeric range, Inc foo-bar for non-numeric. Mirror the plan, do not normalize.

Auto mode honors the same cadence — the per-increment and per-audit commits make a long unattended run easy to bisect after the fact, and each commit is a recovery point if a later step fails.

Step 6 — Completion

When all increments are done or blocked-on-user:

  1. Run pending checkpoints for completed units. Audit any completed work beyond the last recorded audit range before declaring completion.
  2. Run a final check command.
  3. Route open NOTEs. Read the NOTEs recorded in worklog.md during this run. Cluster related NOTEs by module or theme. Write one plan for each cluster with plan-small, or with plan-large when the cluster spans modules or PRs. Do not implement these plans in this run.
  4. Summarize to the user:

Auto mode — failure floors

Auto mode is for unattended runs. Every gate is a hard floor — auto mode will not loop indefinitely. Each of the following stops the run:

  1. Increment implementation fails the layered ladder (implement-plan Step 3.5, Stage 4) → already escalated by implement-plan itself.
  2. Done-criteria check cannot produce evidence (implement-plan Step 3.6) → escalated by implement-plan.
  3. File divergence is material and unexplained (implement-plan Step 3.7) → escalated by implement-plan.
  4. Audit FIX applied → its verify: clause fails → revert that fix, surface, stop.
  5. Audit fixes applied → check command fails the layered ladder → stop, fall back to manual.
  6. A specialist surfaces a QUESTION it can't resolve → stop, ask the user. Auto mode does not guess on blocking questions.
  7. A non-architecture plan-override → apply the fix, propagate the marker, continue. User sees it in the completion summary.
  8. An architecture-level plan-override → apply, propagate, finish the current run-up to the next checkpoint, run that checkpoint, then stop.
  9. A behavior-change FIX → apply, commit, write BEHAVIOR_CHANGE.md, finish the current run-up to the next checkpoint, then stop.

Stopping in auto mode means: print the current state, the merged audit output (if any), the failing diff or failing verify clause, and the contents of BEHAVIOR_CHANGE.md if written. Wait for user input. Do not revert (except for the specific failed-verify FIX in case 4).

Hard floors

Process steps above are the source of truth. Floors that must not slip:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.