agentleFS
talas9talas9/anti-hall/.claude/skills/engine-debug/SKILL.md

engine-debug

Skill2 starsChanged 46 days agoMITView on GitHub

Dev-only, anti-hall repo (not part of the shipped plugin). Use when the ah-engine daemon or a hook misbehaves - high CPU, memory growth, a frozen or crashing daemon, slow hooks, a wrong decision - to find the cause with evidence before any fix, without touching the live daemon's state.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never touch the live daemon's state.

    line 16
  2. Distinctive:

    No rollback of the engine during a live test, and no "restart it and see".

    line 22
  3. Very specific:

    Write the failing test first (see engine-lane), then fix the cause, not the symptom.

    line 50
  4. Distinctive:

    Do not guess a cause from a metric or a log line.

    line 58
  5. Very specific:

    Do not add a threshold, interval or text to Rust source while fixing: it goes in the plugin's engine/defaults/*.toml …

    line 59
  6. Very specific:

    Do not add a flag or environment variable without its entry in flags.toml / engine.toml: the reference drift tests fail otherwise.

    line 61

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

engine-debug: find the cause of an engine problem

Dev-only: lives in the repo's .claude/skills/, outside plugins/anti-hall/, so it is never installed for users. The long form, with commands and a worked example, is the "A debugging session" section of docs/DEVELOPMENT.md (and "CPU and memory profiling" in docs/AH-ENGINE.md). This skill is the checklist for an agent. Every flag, environment variable and key named here is listed in ah-engine/REFERENCE.md.

Safety rules (they win over speed)

  • Never touch the live daemon's state. Read its logs; reproduce in a scratch home (AH_ENGINE_DIR and HOME in a fresh temp directory, which also gives the scratch daemon its own socket). Copy databases with ah-engine backup --to <scratch>, never with a bare cp of a live database.
  • Kill by PID only (kill <pid>). No pkill, no killall: they stop the daemons of other sessions. Track every PID you start and stop exactly those.
  • No rollback of the engine during a live test, and no "restart it and see". Roll back only when hooks exceed their timeout or the guards stop blocking; otherwise fix forward.
  • A debugger or sampler stays attached only as long as its command runs (--batch, then detach). Never leave one on the live daemon.
  • Debug mode is off in normal use. Turn it on for the shortest time that answers the question, then back off (--debug, AH_ENGINE_DEBUG, diagnostics.debug_mode).
  • Bound everything: a build only when load is under 14, nice -n 19, -j 2; delete target/ of a scratch clone when done (move to the Trash, no rm -rf).

Steps

  1. State the symptom with a number. CPU %, RSS, hook latency, exit code. "Slow" is not a symptom.
  2. Health first. ah-engine status --json: health.degraded, health.restarts, health.last_crash, breaker, crash-loop. A cli-crash.json entry is a command-line or hook-client panic and is not a daemon crash.
  3. Logs. The event log ah-engine.log in the state directory, then last-crash.json and its breadcrumb. Quote the lines you rely on.
  4. Name the busy thread. ah-engine status --threads (CPU % per thread name, work counters per second). Do not read code before you know which thread and which counter.
  5. Memory. ah-engine status --memory; then mem.ndjson (per request) and mem-snapshot.json (when the cap tripped). For allocation sites use a scratch daemon with diagnostics.allocator = system or AH_ENGINE_ALLOCATOR=system.
  6. Profile. samply record -p <pid>, or on macOS sample <pid> 5 -file <out> symbolised with atos and the build's ah-engine.dSYM. Symbols match only the binary of the same build (dwarfdump --uuid).
  7. Frozen daemon. Stacks before restart: rust-lldb -p <pid> --batch -o 'thread backtrace all' -o detach -o quit (Linux: eu-stack -p <pid>). Save them, then stop the daemon by PID.
  8. Reproduce in a scratch home with the smallest input that shows the number from step 1. Write the failing test first (see engine-lane), then fix the cause, not the symptom.
  9. Prove the fix with the same measurement as step 1, on the same kind of data. A lab number is not a live number: say which one you have.
  10. Record it. A line in .anti-hall/history/ (Cause / Fix / Verified) and, for a defect, the GitHub issue (gh-work).

Do not

  • Do not guess a cause from a metric or a log line; get the per-item breakdown first.
  • Do not add a threshold, interval or text to Rust source while fixing: it goes in the plugin's engine/defaults/*.toml (no_hardcoded_tunables).
  • Do not add a flag or environment variable without its entry in flags.toml / engine.toml: the reference drift tests fail otherwise.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.