context-compaction-verification-and-recovery
Skill11 starsChanged 5 months agoMITView on GitHub
Use when verifying that tool commands actually executed after compaction.
In this repository26 other files it gives its agents.
- agent-capability-comparison-methodologySkill
- autonomous-work-signalingSkill
- batch-skill-description-standardizationSkill
- checkpoints-and-rewindSkill
- context-aware-task-decompositionSkill
- cross-session-execution-frameworkSkill
- hermes-agentSkill
- hermes-improvement-multiphase-planSkill
- hermes-tweetSkill
- multi-agent-browser-text-extractionSkill
- multi-role-synthesis-frameworkSkill
- openclaw-hermes-archSkill
- open-source-adaptation-patternSkill
- planSkill
- requesting-code-reviewSkill
- router-learning-systemSkill
- security-hardening-checklistSkill
- self-regulation-brake-systemSkill
- skill-slimming-strategySkill
- spec-driven-developmentSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- think-toolSkill
- token-efficiencySkill
- writing-plansSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 12 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Use this protocol when:
- Distinctive: line 40
User says it doesn't render: after you think you've finished — this is the ultimate signal
- Very specific: line 44
Before any "繼續" transition, mentally scan: for every file I claim to have modified, did I actually see a patch() or write_file() success …
- Distinctive: line 48
Before any repairs, run a comprehensive audit:
- Distinctive: line 77
Critical clue: If the file exists but has a smaller size than expected, or if multiple keywords are missing, the patches likely never …
- Very specific: line 113
Write a comprehensive plan (.hermes/plans/YYYY-MM-DD_*recovery*.md)
- Distinctive: line 120
When the recovery plan has 10+ operations:
- Distinctive: line 123
After each phase, do a focused verification: "Phase 1: 5/5 files created" before moving on
- Distinctive: line 124
Keep the todo list granular — one item per file or per logical group, not one "do everything" item
- Distinctive: line 140
After all patches are applied:
- Distinctive: line 173
Use this after any "it doesn't work" report:
- Distinctive: line 198
After applying all recovery patches, run this comprehensive check:
- Very specific: line 208
If DevTools shows "编译 .wxss 文件错误,错误信息如上" with Cannot read properties of undefined (reading 'MaxCodeSize'):
- Very specific: line 211
Check for backdrop-filter usage in recently modified WXSS files
- Very specific: line 212
Check for unbalanced braces in WXSS files ({ vs } counts)
- Distinctive: line 214
After fixing, always clear WeappCache/ before recompiling — stale cache compounds WXSS errors
- Distinctive: line 215
Keep WXSS files under ~15KB per file to avoid exceeding the compiler's code size limit
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Compaction Verification & Recovery Protocol
When to Use
Use this protocol when:
- You've issued multiple
patch,write_file, orcreate_filecalls in a session - Context compaction has occurred (handoff summary mentions "completed" work)
- User reports "偏翼唔到出嚟" (page doesn't render / doesn't work)
- You suspect some tool calls were "spoken but not executed" — written in responses but not actually made
Core Insight
Tool calls that exist only in your reply text but weren't actually invoked will NOT have modified any files. This is the most common failure mode during complex multi-step sessions across context compactions.
Pattern: AI describes what it will do in markdown text blocks, the user says "繼續", and in the next turn the AI treats that description as already done without having made the actual tool calls.
Warning Signs of Compaction-Induced Drift
These patterns strongly suggest patches never landed:
- Deferred tool calls — you say "first I'll X, then Y" in prose, then move on without actually calling the tools
- "As mentioned above" syndrome — you reference code that was typed in your response but never written to disk
- Excessive prose descriptions of code — if you're describing implementation in detail rather than doing it, check if tools were actually called
- User says it doesn't render after you think you've finished — this is the ultimate signal
Prevention: The "Did the tool fire?" Check
Before any "繼續" transition, mentally scan: for every file I claim to have modified, did I actually see a patch() or write_file() success response in my tool output? If you only remember typing it in prose, it didn't happen.
Step 1: Audit — File Existence Check
Before any repairs, run a comprehensive audit:
# Find all NEW files that should exist
# Check each one with ls or search_filesKey files to verify:
- New utility files (
utils/*.js) - New page directories (
pages/*/) - New component files
Step 2: Audit — Patch Verification by Keyword Scan
For each file that was supposed to be patched, scan for distinctive keywords that would only exist after the patch:
# For each patched file, check that NEW method names, variable names,
# or import paths exist in the file content
checks = {
"someFile.js": ["newFunctionName", "newImport", "newVariable"]
}
for fpath, keywords in checks.items():
content = open(fpath).read()
for kw in keywords:
if kw not in content:
print(f"MISSING: {fpath} — no '{kw}'")Critical clue: If the file exists but has a smaller size than expected, or if multiple keywords are missing, the patches likely never executed.
Step 3: Analyze Root Cause
Common causes:
- Context compaction — handoff summary describes work as "done" but tool calls were in a different context and never executed
- Rate limiting / timeout — some tool calls in a batch silently failed
- Wrong file path — patch was applied to a non-existent path
- Middle-of-response tool call — tool call appeared mid-response, earlier compaction truncated it
- ⚠️ 流程規則消失(NEW — 2026-05-01 發現) — Context compaction 唔只導致 code 冇落地,仲會令 流程規則完全消失。最常見:HARD STOP RULES、REVIEW.md 優化授權、Task Size Pre-Judgment Protocol。原因係呢啲規則寫咗落檔案但冇用 memory tool save。Context compaction 後 memory 入面冇呢啲規則,Agent 會當 normal mode 開工,直接 skip boot sequence。
流程規則 Recovery(NEW)
當發現自己 skip 咗 boot sequence / HARD STOP / 其他流程規則:
- 唔好繼續做 code work — 先修復流程
- 用 memory tool 重新 save 所有流程規則
- 行 boot.sh 確認狀態
- 完成後先開始新 work
點樣預防流程規則消失
永遠用 memory tool 而非寫檔案嚟 save 流程規則。
- ❌
database/hermes_memory.jsonpatch — context compaction 後唔會 inject - ✅
memory(action='add', target='memory', ...)— context compaction 後自動 inject
檢查清單(每次 context compaction handoff 後問自己):
- 我記唔記得 boot.sh 係開工第1句?
- 我記唔記得完成 task 要 update ROADMAP + STATE + git commit?
- 我記唔記得 REVIEW.md 優化授權?
- 我記唔記得 task size pre-judgment protocol?
- 以上規則係咪來自 memory tool?(唔係檔案)
Step 4: Recovery Strategy
Approach A — Independent Recovery (preferred)
- Write a comprehensive plan (
.hermes/plans/YYYY-MM-DD_*recovery*.md) - Include: what exists ✅, what's missing ❌, exact patch operations needed
- Share plan with user for approval before executing
- Execute in strict dependency order: new files first, then config changes (app.json), then patches to existing files
- After every batch of 3-4 patches, do a focused syntax check — don't wait until the end to discover a mistake
Approach A.1 — Progressive Recovery (for 10+ missing items)
When the recovery plan has 10+ operations:
- Split into phases (e.g., Phase 1: new files, Phase 2: patches, Phase 3: syntax check)
- Within each phase, group by dependency (a file that other files import from must be created first)
- After each phase, do a focused verification: "Phase 1: 5/5 files created" before moving on
- Keep the todo list granular — one item per file or per logical group, not one "do everything" item
Approach A.1 — Progressive Recovery (new, for 10+ missing items)
When the recovery plan has 10+ operations:
- Split into phases (e.g., Phase 1: new files, Phase 2: patches, Phase 3: syntax check)
- Within each phase, group by dependency (a file that other files import from must be created first)
- After each phase, do a focused verification: "Phase 1: 5/5 files created" before moving on
- Keep the todo list granular — one item per file or per logical group, not one "do everything" item
Approach B — Clean Re-implementation (when patches are too numerous)
- Identify which files need full rewrites vs targeted patches
- For files with 80%+ changes: rewrite entirely
- For files with <30% changes: patch the missing parts
Step 5: Verification After Recovery
After all patches are applied:
# 1. Syntax check all JS files
node -e "require('./utils/new-file')" 2>&1 | head -5
# 2. Check all require() paths resolve
# 3. Check all WXML has matching WXSS classes
# 4. Check app.json has all page pathsStep 6: DevTools Testing
For WeChat Mini Program specifically:
- Clear DevTools cache:
~/Library/Application Support/微信开发者工具/<hash>/WeappCache/ - Close DevTools completely
- Reopen via
open -a "wechatwebdevtools" /path/to/project - Cmd+R compile
- Route to each new/modified page
Common Pitfalls
- "routeTo appLaunch timeout" is often a false positive cold-start latency, not a real error — clear WeappCache and retry before debugging
- Missing
app.jsonpage entry won't cause launch timeout, but will crash when navigating to that page - WXML
wx:ifwith undefined data field renders nothing (no crash, but empty screen) - Mutual require cycles between utils/ files cause silent undefined exports
- The "false positive" trap — during audit, some keywords might already exist from earlier successful patches (recitation.js counter styles were already present even though I thought they were missing). Always verify by reading the actual file, not just keyword grepping.
- WXSS
display: gridwith1frunits triggersCannot read properties of undefined (reading 'MaxCodeSize')in WeChat DevTools — use flexbox withcalc(33.33% - gap)for 3-column layouts - WXSS
filter: drop-shadow()also triggers the sameMaxCodeSizecompile error — replace withbox-shadowinstead backdrop-filterin WXSS is another known DevTools WXSS compiler trigger — works in most files but can cause cascading compile failures when combined with other heavy CSS features
Audit Report Template
Use this after any "it doesn't work" report:
## Pre-Recovery Audit Results
### New Files Status
- [ ] utils/foo.js — EXISTS / MISSING
- [ ] pages/bar/bar.js — EXISTS / MISSING
### Patch Status
- [ ] file1.js — all 8 keywords present / N missing
- [ ] file2.js — all 5 keywords present / N missing
### Config Status
- [ ] app.json — all page paths registered
- [ ] project.config.json — valid
### DevTools Root Cause
- [ ] routeTo appLaunch timeout (likely cold-start latency)
- [ ] require() path mismatch at: _______
- [ ] Missing page config at: _______Final Recovery Verification
After applying all recovery patches, run this comprehensive check:
- Syntax check all modified/new JS files —
node -c filename.js - Check all app.json pages exist — verify js/wxml/wxss triple exists for each
- Keyword scan — re-run the audit against all expected keywords
- DevTools cache clear — remove WeappCache/ and WeappLocalData/ directories
- Reopen DevTools —
open -a "wechatwebdevtools" /path/to/project
WXSS Compile Error Debugging
If DevTools shows "编译 .wxss 文件错误,错误信息如上" with Cannot read properties of undefined (reading 'MaxCodeSize'):
- Most likely cause:
display: gridwith1frunits — replace with flexbox layout - Check for
backdrop-filterusage in recently modified WXSS files - Check for unbalanced braces in WXSS files (
{vs}counts) - Check WXML for
=>arrow functions and?.optional chaining — these WXML errors sometimes manifest as WXSS compile errors in DevTools! Always check WXML first before debugging WXSS. - After fixing, always clear WeappCache/ before recompiling — stale cache compounds WXSS errors
- Keep WXSS files under ~15KB per file to avoid exceeding the compiler's code size limit
When to Write a Plan vs Just Fix
| Scenario | Action |
| 1-3 missing patches | Just fix, no plan needed |
| 3-8 missing patches | Quick audit + execute |
| 8+ missing patches or new files | Write plan first, get user OK |
| User reported "唔work" | Always audit first, then plan |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

