My assistant got the same three rules wrong every time. Kiro's conditional steering fixed it.

2026-12-05来源 dev.toEnglish

I spent the last few weeks building a thing where nothing crashes.

Not in a good way. It's a reimplementation of two file formats from the late
nineties — Winamp 2 skins and MilkDrop presets — and the complete list of
what goes wrong in a codebase like that is:

  • a frame renders black
  • a skin loads upside down
  • a control looks right and is clickable two pixels to the left
  • a visualiser renders a still image instead of moving

Not one of those produces a stack trace. Three of the four produce output
that looks like a design decision.

That turns out to be an unusual environment to use an AI assistant in, because
the normal feedback loop — write it, run it, read the error — doesn't fire.
Everything compiles. Everything runs. The picture is just quietly wrong.

I built it with Kiro, and this post is about which parts
of it earned their keep under those conditions, which parts I had to fix, and
one bug that a property test found on submission day that I'd never have
thought to look for.

The three rules

Here are the rules in this project that an assistant gets wrong by default,
because the default is sensible and these formats are not
:

1. A 32-bit BMP's fourth byte is not alpha. Four bytes per pixel: blue,
green, red, and a fourth one. Obviously that's alpha. It isn't — in skin
sheets from 1999 it's padding, almost always zero, because the header format
has no alpha channel and nobody was reading it as one. Honour it and every
pixel becomes fully transparent. The skin loads perfectly and is completely
invisible.

2. Division by zero yields zero. Not Infinity, not NaN. In ns-eel — the
language inside a .milk preset — 1/0 is 0, and presets rely on it as a
guard-free 1/x. Add the guard the author "forgot" and you've changed what
the preset draws.

3. Audio bands are about 1.0, not 0 to 1. bass, mid, treb are each
divided by a twelve-second running average of themselves, so typical music
sits near 1.0 and the range runs to roughly 8. That's why real presets are
full of max(0, bass - 1) — they react to the delta from normal, which is
what makes a visualiser move with the kick drum instead of with the volume
knob. Pass a 0–1 level and every one of those expressions sits at a constant,
and every preset renders as a still image. Silently.

Every one of those is a thing a competent engineer, or a competent model, will
get wrong on first contact — and then get wrong again next week, because
nothing about the code reminds you.

Conditional steering: the rules arrive with the file

Kiro's steering documents are markdown files in .kiro/steering/ with
frontmatter that decides when they load. Three of mine load always. The
interesting three don't:

--- inclusion: fileMatch fileMatchPattern: 'src/milkdrop/**|worker/**' --- # The preset language 
--- inclusion: fileMatch fileMatchPattern: 'src/{skin,core}/**|tools/make-skin.ts' --- # The skin format 

That's the whole mechanism, and it's the thing I'd take to any other project.
The ns-eel rules arrive whenever anyone opens a file under
src/milkdrop/
. Not when I remember to paste them. Not in a 4,000-line
CLAUDE.md that's 90% irrelevant to the file in front of you.

The second half of why it works is how the rules are written. Every one of
them has the symptom attached:

Get this wrong in either direction and the symptom is not an error. It is a
still image.

Honour the zeroed fourth byte and the entire skin goes invisible.

That's not decoration. In a year I won't remember the rule, but I'll recognise
the symptom instantly — and so will a model that's reading the file for the
first time and trying to work out whether the thing it's looking at is a bug.

If you take one thing from this post: a rule without its symptom is
trivia. A rule with its symptom is a diagnosis.

Specs with a named risk — and tests that cite them

Kiro's specs are requirements.md → design.md → tasks.md per feature,
with EARS-style acceptance criteria. Mine are four features, twelve files.

The convention I added, which isn't a Kiro feature but which Kiro's structure
made obvious: every design document opens by naming the risk it exists to
manage
, and then justifies its decisions against that risk, rejected
alternatives included.

The named risk is a control that LOOKS right and is clickable two pixels to
the left.

The payoff is a trick I'll repeat. The test suite cites the spec by path:

/* * The named risk in .kiro/specs/skin-engine/design.md is a control that LOOKS * right and is clickable two pixels to the left. */ 

Now the spec isn't documentation that drifts quietly out of date. It's load-
bearing. Someone reading the test knows why it exists, and someone editing
the spec gets a hook firing at them (more on that in a second). Specs that
describe an older version of your code are worse than no specs — they're
confidently wrong.

Hooks: the one that refuses your evidence

Agent hooks are JSON files that fire a prompt on a file event. I have five.
The one that mattered most fires on edits to my sprite atlas and says, in as
many words:

Run npm run make:shots, then read the PNGs and describe what you actually
see. Do not report success from the tests alone — every layout bug in
this project was invisible to the tests and obvious in the screenshot.

That's a hook whose entire job is to reject a category of evidence. In a
codebase where the tests can't see the bug, "the tests pass" is not a status
report, and the hook says so at the moment it's most tempting to accept it.

A second one, claims-audit, fires on edits to the README and the submission
docs, and insists every published number be reproducible by a command next to
it. It exists because I once published "19 kB gzipped" that covered JavaScript
only, against a real total of 24.0 kB. The hook names that specific mistake so
it can't repeat — and on submission day it caught a different one: a claim
that the repository "contains no image files" when it ships twenty generated
screenshots. The true claim is that no image is an input. One word, and the
difference between a precise claim and a false one.

Hooks are cheap to write and they are where your scar tissue goes.

Agents as postures, not personas

Three custom agents, each a JSON file with a narrow tool list and a scoped
resource list. None of them has a name like "Senior Architect Alex". They're
working postures:

  • format-archaeologist — reads undocumented binary formats as they actually occur, not as a spec would describe them. Its governing rule: a format with no specification has no invalid files, only files some readers rejected.
  • preset-wright — writes and audits ns-eel equations. Rejects rather than repairs: a line referencing an unknown register is discarded with the reason recorded, and the reason is the interesting output.
  • pixel-inspector — the only part of the project that looks at the output. Renders the real interface headlessly to PNG and describes what it sees. Its rule: if you cannot describe it, you have not looked.

The resources array is the part people skip. Scoping an agent to five files
is most of what makes it behave.

MCP: reads auto-approved, writes not

.kiro/settings/mcp.json wires up fetch, filesystem and git. The
deliberate part isn't which servers — it's the autoApprove lists:

"filesystem": { "autoApprove": ["read_file", "list_directory", "search_files"] }, "git": { "autoApprove": ["git_status", "git_diff", "git_log", "git_show"] } 

Reads are auto-approved. Writes are not, and neither is commit or
push.
The git reads are there because the spec-drift and claims-audit
hooks genuinely need a diff to tell spec-wrong from code-wrong. The absence of
writes is there so a spec-driven run can't quietly rewrite my sprite atlas
while I'm reading something else.

That split took thirty seconds to configure and is the main reason I let the
hooks run unattended.

The property test that found a bug I'd never have looked for

The steering doc for tests specifies property-based testing for anything that
parses untrusted input. The expression compiler takes text from four
directions — files a user drops in, the bundled corpus, equations a language
model wrote, and whatever's in a preset downloaded off the internet — so it
gets twelve properties over arbitrary ASCII, at 300–500 runs each.

The central one:

it('returns a finite double for any source and any register values', () => { fc.assert(fc.property(anySource, fc.array(anyDouble, { maxLength: 24 }), (src, seeds) => { const regs = new Registers(); const { program } = tryCompile(src, regs); if (!program) return; // Poison the register file, including with NaN and infinities. for (let i = 0; i < seeds.length && i < regs.values.length; i++) { regs.values[i] = seeds[i]!; } const out = program.run(regs.values, () => 0.5); expect(Number.isFinite(out)).toBe(true); }), { numRuns: 500 }); }); 

On submission day, running the suite to verify a number for a form, I got 68
passing on one run and 67 on the next
. The counterexample was one string:

"__proto__" 

My lookup tables for functions and constants were object literals:

const CONSTANTS: Record<string, number> = { pi: Math.PI, e: Math.E }; // ... const constant = CONSTANTS[name]; if (constant !== undefined) return () => constant; 

CONSTANTS['__proto__'] doesn't return undefined. It returns
Object.prototype. So a preset containing that single word compiled into a
program that returns an object where every caller expects a double —
sailing past my finite() guard, because Number.isFinite says nothing
useful about an object, and heading for a GPU uniform. Same for constructor,
toString, valueOf, hasOwnProperty.

__proto__(1) was worse: the function lookup succeeded, .arity was
undefined, and destructuring it threw a TypeError — violating a different
property in the same file, the one that promises every malformed input raises
ExprError and nothing else.

The fix is boring (Map instead of object literal — no prototype chain to
inherit through). The point is that no example-based test I would ever have
written contains the string __proto__.
Example tests check the inputs you
thought of. This was definitionally an input I didn't think of, in a component
whose stated threat model is text other people wrote.

It failed about one run in three. A flaky property is not noise — it's a bug
with a low reproduction rate, and the only thing that makes it a flake is
looking away.

What didn't work

Three honest ones:

I wrote hooks that cited npm scripts that didn't exist. My hooks happily
told the agent to run npm run shots when the actual script is
npm run make:shots. A hook that references a nonexistent command is worse
than no hook: it produces a confident failure in the middle of a flow you
weren't watching. Check your hook prompts against package.json.

A fileMatchPattern that doesn't match is invisible. There's no error when
your steering doc never loads. It just silently doesn't help, and you conclude
the feature doesn't work. Open a file in the directory and confirm the
document is actually in context before you trust it.

I didn't use Powers at all. Specs, steering, hooks, agents and MCP covered
everything I needed, and I'd rather report the honest list than pad it.

The thing I'd actually repeat

If your failures are silent — a renderer, a codec, a parser for a format
nobody documented — the ordinary order is backwards. You can't write the code
and then test it, because you won't know which parts were wrong.

So: decide first how you'll see a failure. Then write that decision down
somewhere that loads itself, with the symptom attached, and put a hook on the
file where you'd be most tempted to forget it.

Kiro's contribution isn't that it writes code. It's that it gave me somewhere
to put the three rules so they arrive with the file, and a way to make a test
point at the reason it exists.

Nullwave is MIT-licensed and has zero runtime dependencies. It's an
independent reimplementation of two file formats, unaffiliated with Winamp,
Nullsoft or MilkDrop.

Built for Kiroween 2026.

原文:https://www.a8q9.cn/en/article/my-assistant-got-the-same-three-rules-wrong-every-time-kiro-s-conditional-steeri-5e2c7d.html

相关文章