From predicate
Applies automated refinement loop to audit, optimize, and reduce entropy in codebase artifacts via iterative contraction mapping and fixed-point convergence.
How this skill is triggered — by the user, by Claude, or both
Slash command
/predicate:refineThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Absorb → Audit → Iterate → Sweep → Report**
Absorb → Audit → Iterate → Sweep → Report
This workflow defines the /refine execution loop. The objective is to guide sequence token generation through a series of discrete state transitions (Absorb, Audit, Iterate, Sweep, Report) to systematically reduce the entropy of pre-existing artifacts. The process is modeled as an iterative contraction mapping that halts only when a stable fixed point is verified.
Refining an existing artifact is modeled as finding the unique fixed point $\mathbf{S}^*$ of a state-space contraction mapping. Let $\mathcal{X}$ be the space of artifact configurations, and let $d: \mathcal{X} \times \mathcal{X} \rightarrow \mathbb{R}_{\ge 0}$ be a metric proportional to the residual entropy and count of latent/active flaws. The refinement operator $R: \mathcal{X} \rightarrow \mathcal{X}$ is a contraction if:
$$d(R(\mathbf{A}), R(\mathbf{B})) \le q \cdot d(\mathbf{A}, \mathbf{B})$$
for all $\mathbf{A}, \mathbf{B} \in \mathcal{X}$ and some contraction factor $0 \le q < 1$. By the Banach Fixed-Point Theorem, repeated application of $R$ converges to the unique fixed point:
$$\mathbf{S}^* = \lim_{k \rightarrow \infty} R^k(\mathbf{S}_0)$$
To evaluate convergence in real-time, the error metric $e_k$ is computed using a computable proxy metric $d_p(\mathbf{S}_k)$, defined as the count of unresolved (PENDING or IN_PROGRESS) items in REF_LEDGER. The convergence rate is defined as:
$$\rho_k = \frac{d_p(\mathbf{S}k)}{d_p(\mathbf{S}{k-1})}$$
For a true contraction, $\rho_k \le q < 1$. If $d_p(\mathbf{S}_k) \to 0$, the system is Cauchy-convergent. In practical autoregressive generations:
TRACKED_WORKSPACE_HASHES), the loop has entered an unstable cycle. The system must adapt search parameters (lower generation temperature, inject explicit negative examples, or alter subagent critique rubrics) or execute the rollback protocol to break the attractor basin.Autoregressive Large Language Models do not generate tokens in a vacuum; they traverse a sequence probability landscape where each token step is conditioned on the historical prefix $\mathbf{S}_t$. When the same agent that modified the code also reviews it, the prefix $\mathbf{S}_t$ contains the refiner's internal steps, design rationale, and implicit assumptions. This warps the landscape to construct a deep attractor basin around the refiner's localized choices, mathematically biasing the walk to reinforce its own decisions.
To break this self-congratulatory lock-in and achieve a non-delusional fixed point $\mathbf{S}^*$, validation must execute under Multi-Boundary Subagent Sweeps (MBSS). We project the artifact's state space onto orthogonal axes of critique using independent subagents primed with distinct Initial Boundary Conditions (IBCs) that are completely blind to the refiner's internal trajectory history and to each other's active rubrics or findings, preventing any collusive context leakage.
Refinement is not a process of compliance-driven submission; it is a collaborative, asynchronous synthesis between two expert viewpoints with a single shared goal: offering a genuinely compelling improvement to the codebase that is worth maintaining.
This process rests on a dialectical balance between the refiner (worker) and the reviewers (maintainers) who operate using opposite methods but a unified purpose:
To prevent the system from degrading correct artifacts or entering overcorrection loops, we enforce strict Deterministic Grounding:
HALT (see Section 3 for procedural details).To ensure sequence generations converge to $\mathbf{S}^*$ rather than terminating in local sub-optimal minima, the workflow enforces three control-theoretic bounds that scale dynamically based on the complexity of the task (assessed during ABSORB):
REPORT.
[!IMPORTANT] The Convergence Shortcut still requires executing the full
SWEEPphase. The refiner MUST spawn the independent subagents to verify there are zero findings. Transitioning directly toREPORTfromAUDITwithout running the sweep is a protocol violation.
The exact parameter bounds are initialized in the ABSORB phase based on task complexity (see Section 1). Only when $M_{sweep}$ consecutive sweeps find zero new issues on the final, static codebase state can the system declare convergence ($R(\mathbf{S}^) = \mathbf{S}^$) and proceed to the REPORT phase. Transitioning to REPORT directly from ITERATE or AUDIT is strictly prohibited. Any code modification resets CONSECUTIVE_CLEAN_SWEEPS to 0, requiring a full reset of the sweep phase.
[!IMPORTANT]
/refineis for optimizing and polishing pre-existing artifacts. It is NOT for implementing new features (that's/core) nor for drafting high-level architecture; that strategic work is governed by the Planning Invariants, not this loop. If the sequence begins adding new functional scopes or diverging from the initial target artifact, the walk must halt and return control to the human.
# 1. METADATA
TOPIC: "topic-slug" # Topic slug for the refinement session
STATUS: [ABSORB | CLARIFY | AUDIT | ITERATE | SWEEP | REVIEW | REPORT | HALT]
# 2. CONTEXT
CTX:
TARGET_ARTIFACTS:
- "path/to/target/file"
TEST_FILES:
- "path/to/test/file"
SPECIFICATION_FILES:
- "path/to/specification/file"
ARCHITECTURAL_DOCS:
- "path/to/architectural/doc" # Mapped architectural docs (README, ADR, etc.)
GOAL: "Verbatim objective statement"
MODE: [INTERACTIVE | AUTONOMOUS] # Interactive requires human gates; Autonomous runs under /goal
PREMISE_BYPASS: [TRUE | FALSE] # If TRUE, bypass premise verification halts (defaults to FALSE)
WORKTREE_PATH: "path/to/worktree" # Path to the isolated git worktree
AGENT_BRANCH: "branch_name" # Current active agent branch attempt (e.g., agent/refine-<topic>-attempt-1)
ASSUMPTIONS: [] # Hypotheses logged during autonomous CLARIFY resolution
CONSTRAINTS:
N_MIN: 4 # Adaptive loop limit scaled to task complexity
M_SWEEP: 4 # Adaptive sweep limit scaled to task complexity
K_MAX: 12 # Adaptive divergence boundary
REVIEW_BUDGET: 3 # Max maintainer review cycles before halting
SIBLING_SKILLS: # Sibling skills loaded and consulted during audit
- robust-testing
- engineering
- prior-art
# 3. DYNAMIC REFINEMENT LEDGER
# Track all optimization targets identified during AUDIT or SWEEP phases.
# All items must be RESOLVED before entering the final SWEEP validation gates.
REF_LEDGER:
- ID: R1
AXIS: [CORRECTNESS | API_SUFFICIENCY | COMPLIANCE | EDGE_CASES]
TARGET: "symbol_or_line_or_file"
STATEMENT: "Description of the target improvement"
STATUS: [PENDING | IN_PROGRESS | RESOLVED]
EVIDENCE: "Verification results / test run outputs"
# 4. DYNAMIC REVIEW LEDGER (PR REVIEW)
# Track all nitpicks and design critique targets identified during the REVIEW phase.
# All items must be RESOLVED before human sign-off and merge.
REVIEW_LEDGER:
- ID: N1
AXIS: [CORRECTNESS | API_SUFFICIENCY | COMPLIANCE | EDGE_CASES]
MAINTAINER: [maintainer-architecture | maintainer-complexity | maintainer-documentation]
TARGET: "symbol_or_line_or_file"
STATEMENT: "Nitpick/critique details"
STATUS: [PENDING | RESOLVED]
RESOLUTION: "commit_hash or text justification"
RE_REVIEW_STATUS: [REJECTED | APPROVED]
# 5. ADVERSARIAL SWEEP SYSTEM (MBSS)
# Track the dynamically identified adversarial review angles and subagent sessions.
MBSS_PLAN:
META_AUDITOR_STATUS: [PENDING | APPROVED | BYPASSED_AUTONOMOUS] # Bypassed in autonomous mode if programmed criteria met
ANGLES:
- ID: A1
NAME: "e.g., security-sandbox"
RUBRIC: "Search for specific resource leak or sandbox escape"
SUBAGENT_ID: "conv-uuid"
STATUS: PENDING # [PENDING | PASS | FAIL]
# 6. ITERATIVE TRACE
# Live execution metrics updated at each loop boundary
TRACE:
CURRENT_LOOP: 0 # Current iteration index (k)
INITIAL_STATE_COMMIT: "sha256_hash" # The commit hash of S0 before any modifications
CONSECUTIVE_CLEAN_SWEEPS: 0 # Number of consecutive clean sweeps completed
REVIEW_CYCLE_COUNT: 0 # Current maintainer review cycle index
ROLLBACK_RETRY_COUNT: 0 # Consecutive rollbacks at current state (resets on progress, capped at 3)
TOTAL_ROLLBACK_COUNT: 0 # Cumulative rollbacks executed during the entire run
LAST_RESTORED_LOOP: 0 # Loop index j of the last restored state (defaults to 0)
JUST_RESTORED: null # Optional: transient loop index j just restored from (defaults to null)
FILTERED_CRITIQUES: # Track critiques discarded by verifier/spec triage filters
- SUBAGENT_ID: "conv-uuid"
CRITIQUE: "Subjective styling suggestion"
REASON: [REJECTED_SUBJECTIVE | REJECTED_OUT_OF_SCOPE | REJECTED_FAKE_FAILURE | REJECTED_CASCADE_GUARD]
LOOPS:
- LOOP: 1
RESTORED_FROM_LOOP: null # Optional: loop index j restored from on rollback (defaults to null)
TARGETS_ADDRESSED:
- R1
ERROR_METRIC: 0 # Proxy error count d_p(S_k)
CONVERGENCE_RATE: 0.0 # Computed convergence rate rho_k
TRACKED_WORKSPACE_HASHES: # Content hashes of target, test, and modified files only
"path/to/file": "sha256_hash"
VERIFICATION: "Compiler/linter/test outputs"
COMMITS:
ABSORB ──→ CLARIFY (if goal/scope ambiguity exists)
└─→ AUDIT (if no ambiguity remains)
CLARIFY ─→ AUDIT (once ambiguity resolved)
└─→ HALT (if ambiguity cannot be resolved in autonomous mode)
AUDIT ──→ ITERATE (if ledger has PENDING items)
├──→ CLARIFY (if unexpected environment/dependency ambiguities occur mid-run)
├──→ HALT (if core premise verification fails in any mode, or loop budget/oscillation is detected in interactive mode)
├──→ AUDIT (if loop budget/oscillation is detected and autonomous rollback succeeds)
└─→ SWEEP (if ledger is empty)
ITERATE ─→ AUDIT (once all ledger items are RESOLVED and (CURRENT_LOOP - LAST_RESTORED_LOOP <= K_MAX or CONSECUTIVE_CLEAN_SWEEPS > 0))
├──→ CLARIFY (if unexpected environment/dependency ambiguities occur mid-run)
└─→ HALT (if CURRENT_LOOP - LAST_RESTORED_LOOP > K_MAX and CONSECUTIVE_CLEAN_SWEEPS == 0, loop oscillation is detected, or rollback fails)
SWEEP ──→ AUDIT (if a sweep discovers new issues, or if sweeps pass but limits not met)
└─→ REVIEW (once CONSECUTIVE_CLEAN_SWEEPS = M_SWEEP and CURRENT_LOOP >= N_MIN, or via Convergence Shortcut)
REVIEW ──→ ITERATE (if review findings require code/doc modifications; resets sweep counters)
├──→ HALT (if review budget is exceeded or oscillation detected)
└─→ REPORT (once all maintainers approve, leading to human final merge decision)
Ingest the target artifact, the optimization goals, and any relevant specs or test suites. Setup the tracking ledger in the active sketch file.
CTX.MODE to AUTONOMOUS if executing under a long-running background worker (e.g. /goal), otherwise default to INTERACTIVE.CLARIFY and do not proceed to AUDIT until it is resolved (Halt over assumption).README.md, ADRs, docs in docs/) and log their relative paths in CTX.ARCHITECTURAL_DOCS..worktrees/refine-<topic> based on the active HEAD and create a private branch attempt:
git worktree add -b agent/refine-<topic>-attempt-1 .worktrees/refine-<topic> HEAD
Ensure .worktrees/ is added to the main .gitignore file to prevent untracked file pollution in the user's view. Set CTX.WORKTREE_PATH to .worktrees/refine-<topic> and CTX.AGENT_BRANCH to agent/refine-<topic>-attempt-1.
Note: All subsequent code modification, linter checking, and test runs MUST execute inside the worktree directory, leaving the user's active working directory completely isolated and undisturbed.Adaptive Parameter Bounds Initialization: Evaluate the complexity of the target artifact and goal. Scale the limits dynamically:
Log these parameters and their complexity rationale in the sketch.
Halt sequence generation. Surface obstacles or questions regarding the target artifacts or goals.
AUDIT.ASSUMPTIONS section in the sketchpad and proceed with execution. Only trigger a hard HALT if the ambiguity prevents compilation, linting, or test execution (e.g., a missing library or fatal syntax error).Exhaustively analyze the artifact across four dimensions to identify how to achieve its minimal representation (optimal articulation of the problem space without superfluous complexity). At the start of the audit phase:
CURRENT_LOOP by 1 (representing a new loop cycle $k$) at the start of every audit phase (except when returning from CLARIFY within the same loop).REF_LEDGER with all discovered targets.CTX.ARCHITECTURAL_DOCS. If code changes introduce architectural drift (e.g., public API modifications, new module coupling, changed invariants), the refiner MUST log documentation tasks (e.g. R_DOC_1) in the REF_LEDGER to update the documents during ITERATE.TRACE.LOOPS list in the active sketch file. If TRACE.JUST_RESTORED is not null, set RESTORED_FROM_LOOP of the current loop entry to TRACE.JUST_RESTORED and then reset TRACE.JUST_RESTORED to null in the active sketchpad. To ensure mathematical correctness and avoid blind convergence calculations, metrics MUST be calculated and recorded at the END of the AUDIT phase (after all findings are populated in the ledger, but before transitioning to ITERATE or commencing edits):
PENDING or IN_PROGRESS) items in REF_LEDGER.N/A) if $d_p(\mathbf{S}_k) > 0$.TRACE.LOOPS[CURRENT_LOOP].RESTORED_FROM_LOOP is null, progress has been made; reset ROLLBACK_RETRY_COUNT to 0.CTX.TARGET_ARTIFACTS), test files (CTX.TEST_FILES), and any files modified in the current branch attempt (resolved using git diff --name-only TRACE.INITIAL_STATE_COMMIT HEAD). If a file exists on the filesystem, record its SHA-256 hash. If a file has been deleted in the working tree, record its hash as the sentinel value "ABSENT".HALT (in both interactive and autonomous modes) to prevent turf-polishing via automated assumptions.Sibling Skills Consultation: You are required to actively consult the workspace's sibling skills to think more broadly:
Socratic Purpose Checklist: Evaluate the implementation by asking:
Sieving & Cutting Check (Discriminative Pruning): Counter the additive bias of self-correction loops. LLMs tend to over-engineer solutions by continually adding redundant code, helper parameters, or verbose logic to patch reviewer critiques. Auditing requires active, discriminative pruning:
CTX.GOAL or verified as completely unused by downstream code.REF_LEDGER that are deterministically grounded. Socratic checks and sibling skill reviews (e.g., Hickey simplicity, Lowy volatility) may guide design reasoning, but cannot spawn ledger entries unless they are converted into concrete, reproducible test assertions, spec contract requirements, or compiler/linter rules. Any target added to the ledger by the refiner must be actively verified by executing the compiler, linter, or test runner in the workspace; unverified or hypothesized tool errors are strictly prohibited.If no targets are found in REF_LEDGER, transition to SWEEP (transitioning directly to REVIEW or REPORT from AUDIT is strictly prohibited under any circumstances, even if the initial audit was completely clean). Otherwise, transition to ITERATE.
At the start of ITERATE, reset CONSECUTIVE_CLEAN_SWEEPS to 0 (since codebase modifications are about to occur).
For each ledger item:
CTX.WORKTREE_PATH):
TRACE.LOOPS[CURRENT_LOOP].COMMITS.RESOLVED with evidence..ledger/log/ and commit it within the .ledger/ sub-repository. To automate updating and committing sketch files, you can use the synchronization script from the main repo root:
./skills/refine/scripts/sync_sketch.py [optional custom message]
Transition to AUDIT once all ledger items are RESOLVED.Once the ledger is empty, the refiner MUST execute parallel validation sweeps using independent adversarial subagents. Self-auditing, self-certification, or skipping subagent creation based on the refiner's confidence or the minor size of edits is strictly prohibited and constitutes a fatal protocol violation. Once the ledger is empty:
"You must only report findings that can be demonstrated with a concrete, reproducible test scenario, a compiler error, a specific linter rule violation, or a documented specification contract violation. Banish all stylistic, aesthetic, or subjective suggestions."META_AUDITOR_STATUS: APPROVED.META_AUDITOR_STATUS: BYPASSED_AUTONOMOUS, and transitions immediately.status: [PASS | FAIL]
findings:
- axis: [CORRECTNESS | API_SUFFICIENCY | COMPLIANCE | EDGE_CASES]
target: "symbol_or_line"
statement: "Description of the issue"
evidence: "Linter error, failed test, or spec contract section"
REJECTED_FAKE_FAILURE, logged under TRACE.FILTERED_CRITIQUES in the sketch, and omitted from the active ledger.CTX.SPECIFICATION_FILES, or be documented directly within the active sketchpad. If the cited specification is not in this localized set, the finding must be classified as REJECTED_OUT_OF_SCOPE, logged under TRACE.FILTERED_CRITIQUES in the sketch, and discarded. The refiner must verify if the finding explicitly contradicts a statement, constraint, or invariant documented in those localized spec files. If no documented specification contradicts the current implementation, and no automated tool reports a failure, the finding must be classified as REJECTED_SUBJECTIVE, logged under TRACE.FILTERED_CRITIQUES in the sketch, and omitted from the active ledger.REJECTED_CASCADE_GUARD, logged under TRACE.FILTERED_CRITIQUES in the sketch, and discarded unless it is backed by an automated compiler, linter, or test runner failure.REF_LEDGER as PENDING items.CONSECUTIVE_CLEAN_SWEEPS to 0.META_AUDITOR_STATUS to PENDING.AUDIT.PASS:
CONSECUTIVE_CLEAN_SWEEPS by 1.ROLLBACK_RETRY_COUNT to 0.CURRENT_LOOP = 1), the initial audit was clean, and all subagents pass, the codebase has converged. Transition directly to REVIEW (bypassing N_MIN).CONSECUTIVE_CLEAN_SWEEPS < M_SWEEP or CURRENT_LOOP < N_MIN:
AUDIT to run another sweep cycle. Reset META_AUDITOR_STATUS to PENDING. To ensure diversity on unchanged code, the Meta-Auditor must choose different audit angles or perturb/alter the subagent personas (e.g. increase temperature or change persona roles).CONSECUTIVE_CLEAN_SWEEPS >= M_SWEEP and CURRENT_LOOP >= N_MIN:
REVIEW. (Transition to REVIEW is strictly forbidden if any code or documentation changes have occurred since the last sweep pass, or if CONSECUTIVE_CLEAN_SWEEPS has been reset to 0).This state models a formal Pull Request review under extremely strict and hostile maintainers.
REVIEW_CYCLE_COUNT by 1.maintainer-architecture):
maintainer-complexity):
maintainer-documentation):
REVIEW_LEDGER as PENDING.RESOLUTION. This is the appropriate action when reviewer feedback is valuable for improving the code/docs up to high repository standards.RESOLUTION explaining why the code/architecture must be maintained in its current form. Use this when the refiner must take a stand and defend its choices because the reviewer or subagent misses the bigger, cohesive picture in their myopic review. The refiner must keep the higher-level goal on track, relying on its meticulous progress notes to prevent context loss. Crucially, the refiner cannot resubmit its own bias back into the equation if that bias was previously deferred or challenged.ITERATE (resetting all sweep counters) to compile, check lint, and run the adversarial validation sweeps (SWEEP) on the updated codebase state before returning to REVIEW.REVIEW state and requests re-evaluation from the maintainers.APPROVED. If they reject, it stays PENDING and the refiner must attempt a new resolution.REVIEW_CYCLE_COUNT > CTX.CONSTRAINTS.REVIEW_BUDGET and unresolved ledger items remain, transition to HALT and log a review budget exhaustion report.REVIEW_LEDGER are marked APPROVED by all maintainers, transition to REPORT.If at any loop boundary CURRENT_LOOP - LAST_RESTORED_LOOP exceeds $K_{max}$ (and CONSECUTIVE_CLEAN_SWEEPS == 0), or if oscillation is detected (k >= 2 and $\rho_k \ge 1$ when $d_p(\mathbf{S}_{k-1}) > 0$ and $d_p(\mathbf{S}_k) > 0$ and TRACE.LOOPS[k].RESTORED_FROM_LOOP is null, or if codebase states exhibit exact tracked workspace file hash equality $\mathbf{S}_k = \mathbf{S}_j$ for any prior loop state $1 \le j < k$ stored in TRACKED_WORKSPACE_HASHES when CONSECUTIVE_CLEAN_SWEEPS == 0 and j != TRACE.LOOPS[k].RESTORED_FROM_LOOP):
HALT.TRACE.LOOPS where all regression tests passed. If the codebase starts with pre-existing test failures that the agent is trying to resolve, select the target loop index $j$ that achieved the lowest proxy error metric $d_p(\mathbf{S}_j)$, or default to 0 (representing the initial state $S_0$ before any modifications). Resolve the target commit hash by selecting the last commit hash recorded in the COMMITS list of the TRACE.LOOPS entry where LOOP == j, or default to TRACE.INITIAL_STATE_COMMIT if $j = 0$. If the COMMITS list is empty for loop $j$ (e.g. it was a clean sweep pass), search backwards for the most recent preceding loop entry (where LOOP < j) containing a valid commit hash, or default to TRACE.INITIAL_STATE_COMMIT if none exists.N = TOTAL_ROLLBACK_COUNT + 2.CTX.WORKTREE_PATH), clean up the workspace and check out a new branch attempt from the target stable commit hash:
git restore :/
git clean -fd
git checkout -b agent/refine-<topic>-attempt-N <stable-commit-hash>
This completely isolates the new attempt and preserves the entire history of the previous attempt branch (-attempt-(N-1)) for complete workspace auditability, satisfying global history invariants.CTX.AGENT_BRANCH to agent/refine-<topic>-attempt-N in the active sketch file.TRACE.LAST_RESTORED_LOOP to $j$ and set TRACE.JUST_RESTORED to $j$ in the active sketchpad, and reset CONSECUTIVE_CLEAN_SWEEPS to 0 in the sketchpad. Run the sketch synchronization script from the main repo to commit this state update:
./skills/refine/scripts/sync_sketch.py "docs(sketch): rollback to loop j via branch attempt N"
ROLLBACK_RETRY_COUNT and TOTAL_ROLLBACK_COUNT in the active sketchpad.ROLLBACK_RETRY_COUNT > 3, or if no rollback target state can be resolved from TRACE.LOOPS, transition to HALT and log a failure report.AUDIT and resume.Freeze the execution trajectory immediately. Record a failure report detailing the cause of the halt (unresolved ambiguity, budget exhaustion, rollback failure, review budget exhaustion, or loop oscillation) and return control to the human developer for manual intervention.
HALT, clean up and remove the git worktree to leave the host environment in a pristine state:
git worktree remove --force .worktrees/refine-<topic>
Before generating the final report, execute a post-mortem review of the refinement process itself:
transcript.jsonl under <appDataDir>/brain/<conversation-id>/.system_generated/logs/) and git commit history of the refinement run. Critically evaluate the process: where did the refiner overcorrect, loop inefficiently, deviate from scope, or miss structural simplifications? What could have been done better?agent/refine-<topic>-attempt-N) back into the active main branch, or format it as a single, clean conventional commit.git worktree remove --force .worktrees/refine-<topic>
templates/REFINE.md. Embed the maintainer review results and the post-mortem findings.TRACE.LOOPS for loop $k+1$ (the final state $\mathbf{S}^$) with $d_p(\mathbf{S}^) = 0$ and VERIFICATION: "Fixed-point reached. Consecutive clean sweeps verified." to demonstrate complete convergence.git worktree remove --force .worktrees/refine-<topic>
HALT..ledger/log/ must be updated and committed in the .ledger/ sub-repository at every loop boundary. Do not bundle multiple loops of code modifications and sketch pad updates into a single commit. Automate commits using ./skills/refine/scripts/sync_sketch.py.REPORT are strictly forbidden unless initiated from a passing REVIEW state where all maintainers have approved all items in the REVIEW_LEDGER, followed by the human final merge decision.reset, rebase, or commit --amend on any commit in any user-facing branch) are strictly forbidden across both the main repository and the .ledger/ sub-repository. Backtracking via attempt branches preserves the linear history of all attempts and satisfies global history invariance.git worktree remove --force .worktrees/refine-<topic> on any exit path (REPORT or HALT), leaving the host repository clean and undisturbed.REVIEW_LEDGER must be resolved (via commits or justified rebuttals) and marked APPROVED before presenting the PR to the human.CTX.ARCHITECTURAL_DOCS to identify and resolve document drift, committing documentation updates in the same attempt branch.npx claudepluginhub nrdxp/predicate --plugin predicateAutonomous comprehensive refactoring through a three-phase pipeline: tactical cleanup, architectural restructuring, then final tactical pass.
Reviews Claude Code plugins, skills, codebases, and docs in modes like quick scans, git commit tidying, deep skill analysis, holistic cross-plugin checks, and docs consistency.
Orchestrates a multi-step refactoring pipeline: analyzes code quality, plans improvements, optionally writes tests, implements changes, and reviews results. Routes simple refactors to a lighter workflow.