Skip to content
Back to skills

Matching Decomp

ASecurity

Run a matching decompilation (C/C++ that recompiles to the exact original bytes) efficiently and survive interrupted sessions. Use when starting or continuing a decomp project (splat/INCLUDE_ASM layout, MIPS PS1/PS2/N64/PSP and similar), decompiling functions, orchestrating parallel worker agents, identifying a compiler/assembler's quirks, integrating and verifying the build, or resuming after a crash, rate limit or context reset.

  • 2 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added October 22, 2026
ai-agentspythongoc++git

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned October 22, 2026

npx -y skills add Ketbome/decomp-skills --skill matching-decomp --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Matching Decomp?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Matching Decomp
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ketbome-matching-decomp/badge)](https://www.skillsdirectory.com/skills/ketbome-matching-decomp)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: matching-decomp
description: Run a matching decompilation (C/C++ that recompiles to the exact original bytes) efficiently and survive interrupted sessions. Use when starting or continuing a decomp project (splat/INCLUDE_ASM layout, MIPS PS1/PS2/N64/PSP and similar), decompiling functions, orchestrating parallel worker agents, identifying a compiler/assembler's quirks, integrating and verifying the build, or resuming after a crash, rate limit or context reset.
license: MIT
---

# Matching decompilation

A matching decomp rewrites a game's code in C/C++ so that the original compiler turns it back into the same bytes.
Progress is measured, every step is verifiable, and the work splits into thousands of small independent tasks. That
makes it a good fit for agents, as long as three things hold: **every claim is checked by a byte comparison, every
finished piece is committed at once, and the project's state lives in files, not in anyone's context.**

This skill provides the method, a tool (`scripts/dk.py`, "decomp kit") and templates.

## Pick your situation

| Situation | Read |
|---|---|
| Resuming after a crash, rate limit, `/clear`, new session | [references/recovery.md](references/recovery.md) — always first |
| Starting a new project (split the binary, find the compiler, first match) | [references/setup.md](references/setup.md) |
| Decompiling functions yourself, or as a worker agent | [references/worker.md](references/worker.md) |
| Running several worker agents in parallel and integrating their work | [references/orchestration.md](references/orchestration.md) |
| Which model / effort for a task, when to escalate, how to launch subagents | [references/orchestration.md](references/orchestration.md) ("Choosing models and effort") |
| Being the main session: stay fresh, keep README/AGENTS.md/STATE.md current | [references/orchestration.md](references/orchestration.md) (first two sections) |
| A function "should" match but the bytes differ in a systematic way | [references/toolchain-forensics.md](references/toolchain-forensics.md) |
| Techniques to steer the compiler (registers, order, branches, loops) | [references/matching.md](references/matching.md) |
| Near misses: let decomp-permuter search instead of spending tokens | [references/permuter.md](references/permuter.md) |

## The tool

`scripts/dk.py` (Python 3.9+, `pip install pyelftools tomli`) reads a `decomp.toml` at the project root
([templates/decomp.toml](templates/decomp.toml)). Copy it into the project (`tools/dk.py`) so workers can run it.

```
dk show <func>                 original asm + m2c draft + which source holds it
dk next <src...> [--untried]   INCLUDE_ASM functions, smallest first, flags: jtbl, vu0:N%, fragment?;
                               --untried: without what a worklog mentions or nonmatching/ holds
dk try <src> <func>            pre-check hooks, then compare that function with the original bytes
dk revert <src> <func>         back to INCLUDE_ASM
dk done <src> <log> <msg>      refuse unless every function of <src> matches, then commit <src> + <log>
dk all                         check every written function (after any toolchain change)
dk twins [--list]              copy matched functions onto identical ones (one match -> many)
dk state                       recovery report: STATE.md, uncommitted sources and whether they match, commits,
                               progress, worklog activity, warnings (stale documents)
dk rescue [--commit]           revert work-in-progress that does not match, keep and commit the rest
dk docs [--commit]             regenerate the <!-- dk:NAME --> blocks of README & co. from commands
```

`check` compiles the source privately (safe in parallel), takes the function out of the object and compares it
with the original bytes; fields the linker fills in are compared by symbol and addend, so it proves a match without
linking. The full build (`ninja` or whatever the project uses) stays the final word.

## Rules that make the work efficient and safe

1. **Verify, don't believe.** A function is done only when `dk check` says MATCH; the build is done only when the
   rebuilt binary is byte-identical. Never leave non-matching code in place of the original asm.
2. **Commit each verified unit immediately** (`dk done`), only your own paths, never `git add -A`. A crash then
   loses one function at most.
3. **State in files, numbers from tools.** The orchestrator keeps `docs/STATE.md` (template:
   [templates/STATE.md](templates/STATE.md)), the plan without numbers; every worker keeps a worklog of matches and
   give-ups with reasons. Progress figures come from `dk state` or are generated into documents (`dk docs`), never
   typed by hand. A new session reads those instead of re-deriving anything.
4. **Keep the main session fresh.** It decides and integrates; subagents read code and report in a few lines. Facts
   are re-read from `dk state`, not remembered; decisions are committed to files before the turn ends; the session
   restarts at quiet points with the state loaded by a hook. One instructions file, `AGENTS.md`
   ([template](templates/AGENTS.md)), updated in the same commit as any command or convention it describes.
5. **One owner per file.** Parallel workers get disjoint sets of source files; only the integrator runs the
   splitter, renames symbols, edits shared headers or the build.
6. **Fix the toolchain, not the function.** When many functions fail the same way, the cause is almost always a
   compiler flag or an assembler behaviour (see toolchain-forensics). One fix there unblocks hundreds of functions;
   check every fix against all matched functions (`dk all`) before committing it.
7. **Spend tokens where they pay.** Mid-size model for the per-function loop, small model for mechanical runs,
   strong model with high effort for toolchain forensics (table and escalation rules: orchestration.md, "Choosing
   models and effort"); near misses go to the permuter (CPU), not to fifteen more manual attempts.
8. **Clean room.** Names and types come from the binary, the game's own data and your analysis; never from leaked
   or copyrighted source code. Never commit game data (ISO, extracted files, generated asm).

Files in this skill

  • SKILL.md6.1 KB
  • references/matching.md3.7 KB
  • references/orchestration.md12.2 KB
  • references/permuter.md3.1 KB
  • references/recovery.md3.6 KB
  • references/setup.md4.3 KB
  • references/toolchain-forensics.md8.2 KB
  • references/worker.md4.4 KB
  • scripts/dk.py38.8 KB
  • templates/AGENTS.md3.2 KB
  • templates/STATE.md877 B
  • templates/agent_protocol.md2.7 KB
  • templates/claude-agents/decomp-forensics.md956 B
  • templates/claude-agents/decomp-runner.md527 B
  • templates/claude-agents/decomp-worker.md613 B
  • templates/claude-settings.json325 B
  • templates/codex/agents/decomp-forensics.toml1.1 KB
  • templates/codex/agents/decomp-runner.toml650 B
  • templates/codex/agents/decomp-worker.toml750 B
  • templates/codex/hooks.json338 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.