Aftermath — post-failure recovery skill for AI coding agents


Most agent skills teach how to build. Aftermath teaches how to stop and recover when something already broke: a test suite goes green → red, the same error recurs, a build or dependency resolution fails, a test is flaky, a merge conflicts, a destructive command looms, or the user says "you broke it".
ASCII banner (terminal)
██ ████ █████ ████ ███ █ █ ██ █████ █ █
█ █ █ █ █ █ █ ██ ██ █ █ █ █ █
███ ███ █ ███ ███ █ █ █ ████ █ ████
█ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ ████ █ █ █ █ █ █ █ █ █
stop · revert · recover
Two names, one project
| Namespace | Identifier | Used for |
|---|
| npm | @after.math/aftermath | The npm package: npm i @after.math/aftermath, npx @after.math/aftermath init |
| GitHub | moah0911/aftermath | The repo: source for Claude Code / Codex marketplaces, skills, curl installer |
The npm scope is the publisher's npm account (after.math); the GitHub org is moah0911. They are different namespaces — use the npm scope for npm commands and the GitHub org for marketplace/source commands.
Version status: use ≥ 0.7.0.
npm versions are immutable, so older releases stay visible on the
versions tab
(along with npm's 0.0.0-stage placeholder from the first publish).
0.5.1 — project wiring pointed into the ephemeral npx cache; a real
init crashed after wiring.
0.5.2–0.5.3 — wiring fixed, but before the npm install hooks existed.
0.6.x — npm i wires the agents, but the Claude enable entry was
written into node_modules instead of the project.
0.7.0 — current: project-scoped wiring, host auto-detection, no
cross-agent installs.
Full history: CHANGELOG.md.
Install
npm i @after.math/aftermath # project scope: wires the agent(s) in this project
npm i -g @after.math/aftermath # global: installs the CLI; run `aftermath-install` for user scope
The install script wires whichever agents it finds on your machine:
| Agent | What happens on npm i |
|---|
| OpenCode | Plugin, commands, hooks, and skills are copied into the project; opencode.json gets "plugin": ["./.opencode/plugins/aftermath.mjs"] (a relative path — no symlinks into node_modules, which npm prunes) |
| Claude Code | claude plugin install aftermath --marketplace moah0911/aftermath --scope project (Claude ≥ 2.1.292; older versions fall back to claude plugin marketplace add moah0911/aftermath + claude plugin install aftermath@aftermath) |
| Codex | codex plugin marketplace add moah0911/aftermath + codex plugin add aftermath@aftermath (Codex has no project scope — this is user scope) |
Not installed? Nothing is touched for that agent — the summary just says "not detected".
Opt out entirely with AFM_SKIP_INSTALL=1 or npm's --ignore-scripts.
User scope (all projects)
aftermath-install # wire every detected agent for the current user
aftermath-install --host codex # one agent
aftermath-install --dry-run # show what would change
aftermath-install --uninstall # remove the wiring
User-scope OpenCode wiring stages a durable copy under ~/.config/aftermath/runtime/ and points ~/.config/opencode/opencode.json at it.
Initialize a project
npx @after.math/aftermath init # detect stack + write .aftermath/config.json
npx @after.math/aftermath init --dry-run --json
npx @after.math/aftermath init --run-tests # also record a baseline (opt-in)
init wires only the agent you are running in — it detects OpenCode,
Claude Code (CLAUDECODE), or Codex (CODEX_*) and never touches another
agent's configuration. Use --host opencode|claude|codex|all (or
AFTERMATH_HOST=<host>) to choose explicitly.
Init detects test/build commands, disposable artifacts, and protected paths, then writes
.aftermath/config.json. From then on, rm -rf node_modules or rm -rf dist is allowed
while rm -rf src, .env, .git, and unknown targets stay blocked. It never runs
destructive commands and never enables autoRevert.
Full flags, detection matrix, config schema, and policy reasons: docs/init.md.