Goal: Required Goal
Human-readable metric outcome and target to improve. Subjective cleanup goals are rejected; use ak:cook for those.
/ak:loop
Goal: Reduce TypeScript errors in src/api to zero Quick Ref / Command
Engineer Kit
/ak:loop
Run sequential atomic experiments against a mechanical metric, commit before verifying, keep improvements, revert regressions, log loop-results.tsv, and stop when stuck or unsafe.
Confirm metric fit
Parse or ask config
Safety-screen Verify
Run preconditions
Rule 01
Constraint + mechanical metric + fast verification enables autonomous improvement.
Rule 02
One atomic change per iteration keeps learning interpretable.
Rule 03
Git commits are loop memory; revert preserves history when a trial loses.
Core lanes from input to output, aligned with the command's real execution path.
Start
Input, scope, route
Work
Agent / skill execution
Verify
Gate, review, validation
Close
Report, handoff, artifact
How to invoke the skill: syntax, positional arguments, shared options, then each subcommand with its own syntax and outcome.
Syntax
/ak:loop [Goal/Metric description] or inline config blockGoal: Required Goal
Human-readable metric outcome and target to improve. Subjective cleanup goals are rejected; use ak:cook for those.
/ak:loop
Goal: Reduce TypeScript errors in src/api to zero Scope: Required Editable scope
Glob or search-files patterns for files the loop may edit. The Skill does not widen this scope or edit files owned by the Guard command.
/ak:loop
Scope: src/api/**/*.ts Verify: Required Metric command
Shell command that exits successfully and prints exactly one numeric metric quickly enough to run every iteration.
/ak:loop
Verify: npx tsc --noEmit 2>&1 | grep -c '^src/api/.*error TS' || true Guard: Regression guard
Optional command that must exit 0 for a trial to be kept. Its files are treated as read-only for the loop.
/ak:loop
Guard: npm test Iterations: Iteration cap
Maximum trial count; defaults to 10 when omitted.
/ak:loop
Iterations: 12 Direction: Metric direction
Whether higher or lower metric values are better; defaults to higher.
/ak:loop
Direction: lower Noise: Measurement noise
Measurement treatment: low, medium, or high. Use it to decide repeat and aggregation behavior, not to hide regressions.
/ak:loop
Noise: low Min-Delta: Minimum progress
Smallest improvement that counts as progress; defaults to 0.
/ak:loop
Min-Delta: 1 Each item contrasts a tempting shortcut with the required approach.
Tempting shortcut
“Make it cleaner” can be optimized by taste.
Do this instead
Subjective goals belong to ak:cook or interactive work, not ak:loop.
Tempting shortcut
Run Verify first, then commit if it passes.
Do this instead
Commit before Verify so the loop has memory and can revert losing trials.
Tempting shortcut
Guard files failed; edit them.
Do this instead
Guard files are read-only for the loop.
Concrete invocations for each flag, subcommand, mode, or route available in the live workflow.
/ak:loopGoal: Increase test coverage in src/utils from ~60% to 80% Scope: src/utils/**/*.ts Verify: npx jest tests/utils--coverage
/ak:loop Goal: Reduce main bundle size below 200KB Scope: src/**/*.ts Direction: lower /ak:loop Goal: Drive ESLint error count to zero in src/api Scope: src/api/**/*.ts Direction: lower Iterations: 20 Loop results
Pattern
loop-results.tsv plus final kept/discarded summary, best metric, blockers, and masked logs. The report must mask secrets and explain why changes were kept or reverted.