- If a problem occurs, it must be resolved.
- After resolving a problem, add test cases to prevent regression.
- Everything is testable. If testing is not possible in the current setup, add tools to make it possible.
- Prefer execution over suggestions: if an additional actionable fix is found in the same scope, continue and implement it immediately instead of proposing it first.
- Do not preserve legacy compatibility by default.
- Remove legacy code paths, compatibility fallbacks, and migration shims when touching related areas.
- Treat each change like a day-one design unless the user explicitly requests backward compatibility.
- Prefer schema/bootstrap replacement over incremental migration chains when feasible.
After completing the requested change, immediately continue fixing any build/test/runtime errors discovered during verification in the same scope.
Do not ask for confirmation for these follow-up fixes.
Stop only when:
- A destructive action is required.
- A product decision is required.
- Secrets/credentials are required.
Completion criteria:
- The failing command used for verification passes.
- Related tests pass.
For test validation gates, use pre-commit and pre-push.
Treat both hook stages as required checks when available.
For any web/frontend/runtime-web change, do not stop at smoke-only checks.
Required:
- Start the app with
wrangler dev(local mode unless explicitly requested otherwise). - Validate behavior with Playwright against the running dev server (real browser flow).
- Cover at least one user-visible path relevant to the change (not only
/api/health). - Treat “
wrangler devboot + health endpoint only” as insufficient validation.
- In
zsh, always quote or escape paths containing brackets or glob-like tokens (for example"[id]","[...path]") beforecat/sed/rgcommands. - Do not assume file locations. Verify with
rg --files(orls) first, then read/edit the confirmed path. - Use repository hook scripts at
.githooks/pre-commitand.githooks/pre-pushfor validation gates, not.git/hooks/*. - For GitHub Actions inspection, use the run database ID from
gh run listand validgh run viewflags only. - Use
write_stdinonly for sessions started withtty=trueand still interactive; otherwise rerun the command non-interactively. - Run
node/npm/pnpmcommands in the package directory that ownspackage.jsonand dependencies. - When edits push a TUI source file over 1000 lines, add or update its ownership entry in
crates/tui/long_file_ownership.tomlbefore runningpre-push. - For
wrangler devweb validation, restartwrangler devafter source edits when using custom build hooks; do not assume an already-running instance rebuilt the latest bundle. - Before merging release automation changes, run
cargo package -p opensession --allow-dirtyand ensure publishable crates do not depend onpublish = falseworkspace crates.
Trigger this routine automatically whenever a command, test, hook, or runtime check fails.
- Reproduce the failure with the smallest deterministic command and capture the exact error signature.
- Classify the root cause (
path/quoting,tool-usage,dependency/context,logic/test,infra/flaky) and fix the root cause, not only the symptom. - Add a regression safeguard in the same scope: a test case when feasible, otherwise a validation script/check that fails fast.
- Re-run in this order until clean: originally failing command, related test target,
.githooks/pre-commit, then.githooks/pre-push. - If the same failure signature appears repeatedly, update this
AGENTS.mdwith a new guardrail in the same change.
Follow the canonical loop in docs/harness-auto-improve-loop.md.
- Start from a concrete failing harness command (not a broad workspace run).
- Iterate in a tight fix loop on the smallest scope until stable.
- Promote only after local stability to
pre-commitandpre-push. - Merge only with a regression artifact (test/fixture/check) that would fail without the fix.
- Record repeated failure classes back into this
AGENTS.mdto reduce future entropy.