Show HN: trace2rules – Mine and audit coding-agent logs into AGENTS.md rules A new local-first CLI called trace2rules ingests coding-agent session trajectories, mines recurring friction, and audits existing AGENTS.md and CLAUDE.md rules against real sessions, labeling each rule observed, compliant, violated, unobserved, or already enforced by CI/pre-commit. On the Open-SWE swc-project/swc split of 188 sessions, the tool's audit of the current AGENTS.md found 65 rules: 10 measured, 0 partial, and 55 unmeasured, with rules such as "Commit frequently" violated in 52 of 188 sessions (28%) and "Submodule update before tests" violated in 32 of 32 (100%). The tool outputs proposals rather than applied rules, and its author recommends at least 10 local sessions or a public dataset for useful results. Mine and audit coding-agent sessions into evidence-backed AGENTS.md rules. trace2rules is a local-first CLI. It ingests agent trajectories, mines recurring friction, audits existing AGENTS.md / CLAUDE.md rules against real sessions, and identifies whether each rule is observed, compliant, violated, unobserved, or already enforced by CI/pre-commit. The output is a proposal, not an automatically applied AGENTS.md . Small local corpus? Results are most useful with about 10+ local sessions. With fewer, ingest a public dataset first; see Public datasets public-datasets . Paste this into your coding agent to audit the current checkout: Install trace2rules if missing uv tool install trace2rules . Run trace2rules audit --prompt audit.txt , read audit.txt, and list unobserved, violated, and unenforced rules. Propose concrete enforcement without duplicating existing CI/pre-commit checks. Or run the deterministic audit manually: trace2rules audit Paste this into your coding agent to generate rules: Install trace2rules if missing uv tool install trace2rules . Run trace2rules mine --prompt --out-dir prompts/ for my local agent sessions. Read the prompt files and synthesize repo-specific AGENTS.md rules yourself. Keep only rules supported by the evidence. Or generate the evidence prompts manually: trace2rules mine --prompt --out-dir prompts/ See Auditing AGENTS.md auditing-agentsmd and Generating rules generating-rules for the full flows. trace2rules audit is deterministic: it prints counts, coverage, verdicts, enforcement status, and deterministic suggestions. For a fresh-agent review, emit the evidence prompt: trace2rules audit --prompt audit.txt Give audit.txt to your agent. The LLM receives the audit table but not the deterministic suggestions. After the agent writes proposed rules, validate them: trace2rules audit --proposal AGENTS.proposed.md --proposal parses the proposed Markdown, audits it against sessions, and prints verdicts before you apply it. On the Open-SWE swc-project/swc split 188 sessions , the current AGENTS.md audit finds 65 rules: 10 measured, 0 partial, and 55 unmeasured. | Rule | Followed | Violations | Confidence | Enforcement | |---|---|---|---|---| | Commit frequently | 136 | 52/188 28% | high | missing | | No nightly-only rustc features | 172 | 16/188 9% | low | missing | | Use gh for GitHub data | 18 | 6/24 25% | medium | .github/workflows/CI.yml | | Snapshot update with UPDATE=1 cargo test | 23 | 2/25 8% | medium | missing | | --no-verify guard | 13 | 1/14 7% | low | missing | | Read the codebase before editing | 123 | 62/185 34% | high | guidance only | | Verify assumptions against source/tests | 123 | 62/185 34% | high | guidance only | | Submodule update before tests | 0 | 32/32 100% | medium | guidance only | | git commit only after git add | 8 | 6/14 43% | low | guidance only | | cargo test -p