#!/usr/bin/env node /** * Add Token Checkpoint Monitoring Instruction * * Adds inst_075 to instruction-history.json for checkpoint monitoring enforcement */ const fs = require('fs'); const path = require('path'); const INSTRUCTION_HISTORY_PATH = path.join(__dirname, '../.claude/instruction-history.json'); // Read current instruction history const history = JSON.parse(fs.readFileSync(INSTRUCTION_HISTORY_PATH, 'utf8')); // Check if inst_075 already exists const exists = history.instructions.find(i => i.id === 'inst_075'); if (exists) { console.log('inst_075 already exists - skipping'); process.exit(0); } // Create inst_075 const inst_075 = { "id": "inst_075", "text": "AFTER each response, check for current token count. IF token count > next_checkpoint value in .claude/token-checkpoints.json, MUST run: node scripts/check-token-checkpoint.js --tokens [current]/[budget]. This generates pressure report and marks checkpoint as completed. Checkpoints are at 25% (50k), 50% (100k), 75% (150k). Checking checkpoints is MANDATORY, not optional. Token budget awareness prevents context window exhaustion and maintains quality.", "timestamp": new Date().toISOString(), "quadrant": "SYSTEM", "persistence": "HIGH", "temporal_scope": "PERMANENT", "verification_required": "MANDATORY", "explicitness": 0.95, "source": "framework", "session_id": "2025-10-23-framework-analysis", "parameters": { "checkpoint_script": "scripts/check-token-checkpoint.js", "checkpoints": [50000, 100000, 150000], "verification_required": "MANDATORY", "automation_trigger": "after_response" }, "active": true, "notes": "Created in response to token checkpoint enforcement failure (session passed 96k tokens without reporting at 50k and 100k thresholds). Makes checkpoint monitoring architecturally enforced through HIGH persistence instruction. Prevents context window exhaustion and session quality degradation.", "created_date": "2025-10-23", "incident_response": "token_checkpoint_enforcement_failure_2025_10_22" }; // Add to instructions array history.instructions.push(inst_075); // Update metadata history.last_updated = new Date().toISOString(); // Write back to file fs.writeFileSync(INSTRUCTION_HISTORY_PATH, JSON.stringify(history, null, 2)); console.log('✅ Added inst_075: Token checkpoint monitoring'); console.log(` Total instructions: ${history.instructions.length}`); console.log(` Active instructions: ${history.instructions.filter(i => i.active).length}`);