
A few weeks back I posted about https://github.com/code3hr/cyxcode — our OpenCode fork that intercepts known errors with regex patterns before burning LLM tokens.
That solved repeated errors. But there was another token drain we kept hitting: repeated corrections.
The problem:
You're coding. Terminal crashes. You reopen, run --resume. The AI has no idea what you were doing. CLAUDE.md wasn't updated before the crash. You spend 10 minutes re-explaining.
Or worse: you correct the AI's behavior. "Use conventional commits." It follows. Context compacts. Correction gone. You correct again. By the 5th time, you've burned 1,000+ tokens saying the same thing.
Patterns saved us from repeated errors. We needed something to save us from repeated corrections.
State versioning:
CyxCode now commits your AI's state on exit — even crashes:
Terminal closes (Ctrl+C, crash, SIGHUP)
↓
Exit handler fires
↓
State committed:
├── goal: "Add JWT auth to API"
├── inProgress: "Fix token expiry"
├── workingFiles: [auth.ts, middleware.ts]
├── discoveries: ["tokens used wrong secret"]
└── corrections: [{rule: "use conventional commits", strength: 3}]
Next session: "update me from last conversation"
AI already knows what you were doing. No re-explaining.
---
Correction tracking:
You correct AI → strength: 1
Correct again → strength: 2
Third time → strength: 3 → AUTO-PROMOTED
Strength 3 = permanently injected into every session. The AI can't forget it.
We also added drift detection — if the AI stops following a learned behavior, it gets auto-reminded.
---
Token math:
| What | Before | After |
|------------------------------------|---------------|-------------------|
| Resume after crash | ~20K tokens | ~200 tokens |
| Correction repeated 5x | 1,000 tokens | 200 tokens (once) |
| Pattern match (from original post) | ~1,500 tokens | 0 tokens |
Patterns handle repeated errors. State versioning handles repeated corrections.
---
What it's NOT:
This saves session context, not code. Git tracks your files. CyxCode tracks what the AI knew and was doing.
---
Current stats:
- 170+ error patterns (up from 136)
- Auto-commit on exit (SIGINT, SIGTERM, SIGHUP)
- Correction strength scoring + auto-promotion
- Drift detection + auto-remind
- Resume injects previous session context
---