commit 760b03fd2902d0ccfaae3669be69b26755f652f9 (tree)
parent 9b0020fe40074d122fa93f2987d0ad20fcc23c42
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date: Sun, 15 Feb 2026 18:38:28 +0000
update skill
Diffstat:
2 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/stage0/.claude/skills/port-astgen/SKILL.md b/stage0/.claude/skills/port-astgen/SKILL.md
@@ -14,12 +14,21 @@ then verify and commit.
**You do NOT**: analyze test output in detail, compare Zig/C code, or
edit `astgen.c`. The worker handles all of that.
+**CRITICAL RULES:**
+1. **NEVER stop early.** Do not pause to ask the user if you should continue.
+ Do not summarize remaining work and wait. Keep looping until every test is
+ enabled and passing.
+2. **ALWAYS run `zig build all-zig0 -Dvalgrind |& grep -v Warning | head -20`
+ yourself before committing.** Never trust the worker's claim that tests pass
+ — verify it. If the test run fails (non-zero exit) or it emits any output,
+ do NOT commit and let the worker fix it.
+
## Phase 0: Check for leftovers
Before enabling anything new, run the existing tests:
```sh
-zig build test-zig0 2>&1 | head -20
+zig build test-zig0 -Dzig0-cc=tcc 2>&1 | head -20
```
If tests **FAIL**: dispatch a worker (Step 4 below) with context
@@ -66,7 +75,7 @@ line to enable the test.
Run:
```sh
-zig build test-zig0 2>&1 | head -10
+zig build test-zig0 -Dzig0-cc=tcc 2>&1 | head -10
```
Capture only the first ~10 lines. This tells you pass/fail at a glance
without bloating your context. The worker will run the full test itself.
@@ -95,20 +104,17 @@ The worker returns a structured result. Extract:
**If STATUS is `pass` or `progress`:**
-Launch a sub-agent to run:
+**You MUST verify before committing.** Run:
```sh
-zig build fmt-zig0 && zig build all-zig0 -Dvalgrind |& grep -v Warning
+zig build all-zig0 -Dvalgrind |& grep -v Warning | head -10 ; echo "EXIT: $?"
```
-This must exit 0 with no unexpected output. The agent must investigate:
-1. Any valgrind errors.
-2. Any debug output (should comment out printf statements).
-3. Any formatting or staticcheck issues.
-4. Any failing tests — should not happen as the worker verifies before
- returning, but if it does, the sub-agent should fix them.
+Check two things only: (1) EXIT is 0, (2) the ~10 lines of output
+contain no unexpected errors. If either check fails, do NOT commit —
+dispatch another worker to fix.
-Then commit:
+Only if clean, commit:
```sh
git add stage0/astgen.c stage0/astgen_test.zig
diff --git a/stage0/.claude/skills/port-astgen/worker-prompt.md b/stage0/.claude/skills/port-astgen/worker-prompt.md
@@ -26,7 +26,7 @@ return a result.
### Step 1: Run the full test
```sh
-zig build test-zig0 2>&1
+zig build test-zig0 -Dzig0-cc=tcc 2>&1
```
Record the full output. If tests pass, skip to Step 5.
@@ -60,8 +60,16 @@ Do NOT guess. Read both implementations completely and compare mechanically.
### Step 4: Port the fix
-Apply the minimal mechanical change to `astgen.c` to match the upstream. Run
-`zig build test-zig0 -Dcc=tcc` after each change to check for progress.
+Apply the minimal mechanical change to `astgen.c` to match the upstream.
+Make ONE change at a time. After each change, run:
+
+```sh
+zig build test-zig0 -Dzig0-cc=tcc 2>&1 | head -20
+```
+
+Check that no previously-passing tests broke. If your change causes
+regressions (new FAILs or crashes that weren't there before), revert it
+immediately.
**Progress** means any of:
- `inst_len` diff decreased
@@ -73,9 +81,6 @@ You should mark progress marker (whatever it is from the above) *in/near
the disabled test entry* (as a TODO comment on the SkipZigTest line or
above the commented corpus entry).
-Once there is *any* progress, you MUST clean up and commit per sections below.
-Do not try to fix everything at once -- clean up & commit early & often.
-
### Step 5: Clean up
1. Remove ALL `fprintf`/`printf` debug statements from `astgen.c`.
@@ -85,9 +90,9 @@ Do not try to fix everything at once -- clean up & commit early & often.
line with a TODO comment describing the remaining diff.
- **For a corpus entry:** re-comment the line in `corpus_files` (add `//`
prefix back) and add a TODO comment above it describing the remaining diff.
-4. Test if other compilers or valgrind did not regress, fix if it did:
+4. Final verification — this must exit 0 with no output:
- zig build fmt-zig0 && zig build all-zig0 -Dvalgrind |& grep -v Warning
+ zig build all-zig0 -Dvalgrind |& grep -v Warning | head -100
### Step 6: Return result
@@ -111,7 +116,9 @@ COMMIT_MSG: <one-line descriptive message about what was ported/fixed>
X, do X in C.
- **Never remove zig-cache.**
- **NEVER print to stdout/stderr in committed code.** Debug prints are
- temporary only.
+ temporary only. Before returning, grep for `fprintf\|printf` in
+ `astgen.c` and remove any you find.
+- **Do NOT commit.** The orchestrator handles all commits.
- **Functions must appear in the same order as in the upstream Zig file.**
- **Prefer finding systematic differences for catching bugs** instead of
debugging and hunting for them. Zig code is bug-free for the purposes of