Deft directive pre pr

From deftai/directive · View interactive version

Deft directive pre pr is an AI agent skill from the GitHub repository deftai/directive. Iterative pre-PR quality improvement loop. Use before pushing a branch for PR creation -- after completing implementation. Cycles through Read-Write-Lint-Diff plus verify:ac until a full pass produces zero changes.

How to use this skill

Skill file

<!-- AUTO-GENERATED by task packs:render -- DO NOT EDIT MANUALLY -->

<!-- Purpose: rendered skill -->

<!-- Source of truth: packs/skills/skills-pack-0.1.json -->

<!-- Regenerate with: task packs:render -->

<!-- Edit the source, not this file. Slice instead of loading every SKILL.md: task packs:slice skills by-trigger --trigger <kw> (or list) -->

Deft Directive Pre-PR -- Read, Write, Lint, Diff, Loop

Structured self-review loop agents run before submitting a PR. Catches inconsistencies, missing enforcement markers, incomplete acceptance criteria, scope creep, and unintended changes before they reach the reviewer.

Legend (from RFC2119): !=MUST, ~=SHOULD, ≉=SHOULD NOT, ⊗=MUST NOT, ?=MAY.

See also: deft-directive-review-cycle | deft-directive-build | RWLDL tool

Formerly deft-rwldl -- renamed and scoped to PR readiness. For the broader iterative quality improvement loop (micro/macro review), see tools/RWLDL.md.

Branch-Protection Policy Guard

! Before entering Phase 1 (Read), run the skill-level branch-policy guard documented in task policy:show / dual-invoke deft verify:branch (#746 / #747). Halt before any state mutation (the Phase 2 Write phase, the Phase 3 Lint phase that may touch files) when the policy is unresolvable AND no env-var bypass is active:

deft verify:branch

or task deft:verify:branch when the consumer Taskfile include is present. Do not add a consumer verify:branch task. Pre-PR is the last gate before push, so a stale / unresolvable policy here is the highest-leverage place to catch the bug before it reaches the bot reviewer.

Deterministic Questions Contract

! Every numbered-menu prompt rendered in this skill (per-finding decision menus in Phase 4 Diff, the Phase 5 Loop restart-vs-exit gate) MUST follow CODE0: the final two numbered options MUST be Discuss and Back, in that order. The Discuss-pause semantic is documented verbatim there -- implicit resumption is forbidden.

Ordered-plan target gate (#2402)

! Before opening or pushing a PR, when an ordered-plan sequence may be active, verify the work unit matches the current authorized entry:

  1. Resolve the current entry kind and id:
task plan-sequence:current

Use task plan-sequence:current -- --json when you need machine-readable kind / id fields from the current entry.

  1. Verify with the entry kind (not hardcoded pr — story / issue entries are common):
task verify:plan-sequence -- --target-kind <entry-kind> --target <entry-id>

Three-axis candidate validation (#4888)

GitHub mergeable_state is textual only. Post-open behavioral/policy gates stay invisible until the merge-chokepoint task check / deft check runs against the current base (#4888).

Gate throughput — iteration fast lane vs merge chokepoint (#1704)

Invariant: every change MUST pass the full gate at least once before merge. Ordinary pre-PR is the scoped Read-Write-Lint-Diff-Loop plus verify:ac — not the whole-repo merge chokepoint. CI task check:merge (and conflict-resolve / behind-rebase locally) hold the full gate (#6040).

When to Use

Controller invocation (#4912)

! Start the prescribed pre-PR workflow through deft pre-pr:run. Opening this skill file is not completion. A generic mark-complete cannot mint a pass.

Live skip detection on deftai/directive additionally requires Limb 5 enrollment (#4976).

Hard local refuse before push (#5804)

! On enrolled tip OVPR, feature-branch git push of product/test changes fails closed unless a private-store deft pre-pr:run pass bound to HEAD covers outgoing paths (outgoing ⊆ reviewed pushBinding). Empty pre-push stdin denies. The managed hook enrolls only when plan.policy.requireBoundPrePrPush is true; false or not set means it does not look for a pass (#6893).

Lifecycle-only PRs keep review (#6280)

! No PR class skips the review bot. This includes PRs that change only xbrief/ lifecycle files. A repo with no reviewer installed is the separate #3630 terminal, not a PR class.

In-PR completion is the default for a story's last product PR (#6277)

Loop Phases

Each iteration proceeds through all phases in order. Do NOT skip phases or reorder them.

Phase 1 -- Read

! Re-read each changed file end-to-end (git diff master --name-only to get the list).

Phase 2 -- Write

! Fix any issues found in the Read phase.

Phase 3 -- Lint

! Run the scoped iteration-lane gates and fix any failures (#6040). Ordinary pre-PR does not run a post-loop full task check.

~ Windows + Grok Build (#1353): Avoid |, >, or 2>&1 in run_terminal_command strings -- use Python pathlib/subprocess or plain task commands instead.

Phase 3c -- Coverage headroom (optional; not prompted in ordinary pre-PR) (#6040)

Ordinary pre-PR does not run coverage or require coverage_headroom. The controller row stays in PRE_PR_PHASES as required: false. If an agent observes a red optional coverage row, the run still fails — so do not prompt or record that phase in ordinary pre-PR.

Phase 3b -- Auto-Render Exports

! If xbrief/specification.xbrief.json exists, refresh rendered exports before the diff check:

Phase 4 -- Diff

! Review the full diff against the base branch for unintended changes.

git --no-pager diff master

Phase 5 -- Loop

! Decide whether to restart or exit.

Budget-aware pre-PR depth (#3266)

When session effort-budget is hard-capped (DEFT_MAX_TURNS / DEFT_MAX_BUDGET / session:start effort_budget):

Product-first done-gate (#3284) / literal AC (#3267)

Product-oracle gate integrity (#3322 / #3156)

A red product verification may be resolved only by a product change or an independently re-derived oracle (both sides rebuilt from scratch, different method). In-place repair of the failing comparison then pass is not a pass — it is an unresolved discrepancy.

Probe-then-fill remote claims (#3120)

! Before filling any remote handoff field (PR URL, PR number, commit/HEAD SHA, CI green/success, review score) or claiming status: pass / ship/gate done, MUST probe then fill:

  1. Run same-turn git + forge probes (examples: git rev-parse HEAD, gh api repos/<owner>/<repo>/pulls/<N>, task pr:watch -- <N> --one-shot, checks API).
  2. Copy IDs / URLs / SHAs / scores only from that probe JSON/text into the evidence block.
  3. Set proof_status: bound and attach short raw probe snippets (command + snippet) for each remote claim.

! Handoff evidence axes: work (local) / ship (pushed branch or PR) / gate (CI/review on HEAD). proof_status is bound | unbound | n/a-no-remote-claim.

! Legal partial: local work done + ship not_started / blocked without PR/SHA/CI/review fields and proof_status: n/a-no-remote-claim (or status: partial) is valid — do not invent ship state.

! Fail ranking: invented-done (false/unbound remote artifacts under pass) is stricter than empty-done. Unbound remote claims → invalid evidence (fail), not pass-with-notes.

! Machine check: validateHandoffEvidence in packages/core/src/handoff-evidence/ (see templates/agent-prompt-preamble.md §11).

⊗ Fill PR / SHA / CI / review fields from recollection, narration, or prior-turn memory.

⊗ Claim status: pass with remote fields when proof_status is not bound or probes are missing (#3120).

First-PR-open closed-PR path-intersection (#1178)

! Own the first-PR-open closed-PR path-intersection pass here (and any implement-leaf gh pr create bypass MUST call this same contract). Swarm Phase 6 stays merge / protected-issue / finalize and MUST point at this pre-pr owner — ⊗ treat Phase 6 as the first-open closed-PR search owner.

Shared retrieval tokens match article-review pre-filing (#1178): closed-PR walk uses named default PREFILING_CLOSED_PR_WINDOW = 100, outcome tokens window-exhausted | list-exhausted | cap | error, and file-list pagination must complete before path-intersection.

Exit Condition

! Exit when a complete Read-Write-Lint-Diff cycle produces zero changes -- no file edits in Write, no lint fixes in Lint, and no scope issues in Diff.

After exiting:

Significant decision log (#1396)

! Before push, if this PR encodes a significant choice not already recorded, run task decision:write (significance filter: architecture, product behavior, security, boundaries, data model, topology, hard-to-reverse process).

~ Check task decision:list for related process policy so the PR does not silently reverse a dogfood decision.

⊗ Invent revisit-free rationale in the PR body as a substitute for a decision record when the choice is significant.

⊗ Noise the log with trivial scope completions.

Docs: docs/decision-log.md.

Anti-Patterns

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.