flightwake trap registration — write a non-obvious trap into the TRAPS registry. Use immediately when a surprising root cause is found (weird error, vendor quirk, encoding trap), or when the user says log this trap / trap.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Fw Trap?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/kaiwutech-tw-fw-trap-acd38990)
---
name: fw-trap
description: flightwake trap registration — write a non-obvious trap into the TRAPS registry. Use immediately when a surprising root cause is found (weird error, vendor quirk, encoding trap), or when the user says log this trap / trap.
---
# fw-trap — trap registration
Purpose: any given trap gets stepped in exactly once per project (including future sessions and other agents).
## What qualifies for TRAPS
- Symptom and root cause are **far apart** (e.g., jsonb stored as a string scalar → root cause is the driver's encoding of "string parameter + ::jsonb")
- Undocumented vendor behavior (e.g., some operation path doesn't fire the webhook)
- Environment-difference traps (passes locally, explodes in prod)
- **Doesn't qualify**: ordinary bugs, anything obvious from reading the error message
Two questions before writing (a registry that only grows collects entries nobody needs):
1. **If this entry did not exist, would the next agent or person still be likely to step in it?** No (the fix is in
place and nothing leads back to it, or the error message now says it all) → don't record it.
2. **Can it be a test, a lint rule, a check in a script or a line in the code's own error message instead?** Yes →
do that; a test costs no context and can't go stale unnoticed. Record a trap only for what can't be enforced.
## How sure is the root cause (confidence)
The registry's most expensive failure isn't a missing entry — it's **a misdiagnosis written as settled fact**.
Readers can't tell "nailed by a controlled experiment" apart from "the most likely story at the time," and
following a wrong root cause takes you further off course than having no registry at all. So rate the root cause:
| confidence | Meaning | Evidence required |
|---|---|---|
| `confirmed` | Controlled experiment: toggle the cause → symptom appears/disappears, at least twice. For **non-causal** facts (does a feature exist, what's on the list, how does this version behave), substitute "exhaustive direct verification + a primary source you can point at" (source line numbers / official docs / item-by-item check in the console) | Evidence field must point at that experiment or that source |
| `probable` | Consistent across several observations, but no control group | State how many observations, over what period |
| `suspected` | Single observation, or "the most likely explanation at the time" | State **what you haven't ruled out yet** |
Three rules:
1. **The symptom field is always fact** (paste the error verbatim); confidence rates only the root cause field
2. Below `confirmed`, write the fix as a **workaround**, never a "fix" — and **never treat it as a rule**
3. **Asymmetric bar** — using this trap to argue "**this breaks**" → `probable` is enough (being wrong just
costs extra caution); to argue "**this is safe**" → it must be `confirmed` (being wrong hits prod and your users directly)
Raising confidence (suspected → confirmed) is an **in-place edit of the same entry**, not a supersede;
supersede is reserved for when the root cause itself changed. The same rule decides when the pre-write check (step 1) finds a candidate.
## Steps
1. **Check for a near-duplicate before writing**: run (read-only; it reads TRAPS.md and nothing else)
```bash
npx flightwake traps similar --name='<slug>' --tags='<a,b>' --paths='src/db/**,*.sql' --commands='npm run migrate,psql' <<'EOF'
<symptom (the error, pasted verbatim) + root cause in one sentence>
EOF
```
The text goes in through the quoted heredoc (`<<'EOF'` … `EOF`, the closing `EOF` alone at the start of its line) and every
other value in single quotes — never double quotes: inside them the shell runs backticks and `$(…)` from a pasted error.
Leave out `--paths` / `--commands` when the entry has none.
If it lists candidates, pick one of three instead of simply adding another entry:
- **update the existing entry in place** — same root cause: more evidence, more paths/commands; a confidence upgrade (suspected → confirmed) is this case
- **supersede** it — the root cause itself changed: as in step 6, set the old entry's `status: superseded` and point its body at the new [[name]]
- **record a new entry anyway** — a different root cause: in the new entry's body, write one line saying why it is not the same as the candidate
A candidate marked "same name" rules out a new entry under that name. No candidates → go on and write it.
Command unavailable (offline, an older flightwake, no Node)? Do the same check by hand: grep `.flightwake/TRAPS.md` for the new entry's
tags, paths and key error words, and make the same three-way choice for any close entry
2. Follow the entry format demonstrated at the top of `.flightwake/TRAPS.md` (OKF-style frontmatter: name/type/status/confidence/tags/discovered)
and write it at the **top** of `.flightwake/TRAPS.md`
Optional: `paths` / `commands` — fill them when the trap belongs to particular files or commands, so the trap check (the PreToolUse hook in Claude Code and Codex, and the optional Claude Code mod) can
show the entry right after an agent touches them: `paths: ["src/db/**", "*.sql"]` (repo-relative globs; a pattern without `/` matches that
file name at any depth), `commands: ["npm run migrate", "psql"]` (command prefixes, word by word). No regex. Not sure, or the trap is
about an idea rather than a place? Leave them empty — the entry works the same without them
Optional: `retire_when` — one line saying when the entry can be marked superseded (e.g. `retire_when: "Codex hooks load under codex exec"`,
`retire_when: "a smoke check enforces it"`). Compaction reads it first.
3. All four fields: symptom (paste the original error message), root cause in one sentence, fix/workaround, evidence link (commit/record)
4. Link related traps with `[[name]]`
5. **Write the symptom on the spot** — details fade within half a day. **Leave the root cause unsettled until it's nailed**:
if it isn't, mark `confidence: suspected` and note what you haven't ruled out. Don't leave the entry unwritten while
you think, and don't dress a guess as a conclusion. Come back and raise it once you've nailed it
6. When a new trap **replaces or covers** an existing entry: set the old entry's frontmatter `status` to `superseded` and point its body at the [[new entry]] — never delete lines,
so an "old md vs new md" conflict always has a clear direction
7. Judge the trap's **scope**: if it isn't specific to this repo — any project would step in it (platform/language/tool layer, e.g. Node stdin behavior, shell expansion) —
still register it in TRAPS (the repo's registry must be self-contained: the next person or agent can't see your personal memory),
**and save a copy to your user-level memory** (e.g. Claude memory) so your other repos don't re-trip it.
One copy per scope is division of labor, not duplication: a generic trap recorded in only one repo bites again in the next repo
8. **Antigravity in this repo** (`.agents/hooks.json` has `flightwake-state-check`) **and the entry has `paths`**: run
`npx flightwake traps rules` after writing. It regenerates `.agents/rules/flightwake-trap-*.md` from TRAPS.md, which is how
Antigravity sees the trap before it edits those files. Never edit those generated files by hand.