๐ Generic project automation system with anti-compaction protection and recovery capabilities. Automatically detects project type (React, Node.js, Python, Rust, Go, Java) and provides intelligent analysis. Claude Code optimized - run 'welcome' after inst
npm install claude-code-automationUniversal anti-compaction system with perfect recovery capabilities for Claude Code projects
> โ ๏ธ Note: This package is specifically designed for Claude Code AI assistant sessions and will not work with other AI tools (ChatGPT, Copilot, Cursor, etc.).


;, &&, ||, |, etc.)--verbose flag for detailed operation feedbackContext Loss is the #1 problem when working with Claude Code:
- โ Long sessions lose context due to token limits
- โ Complex projects get "compacted" and lose detail
- โ Recovery is manual and error-prone
- โ Progress gets lost between sessions
Code Automation provides:
- โ
Fixed critical installation bug - All automation files now install correctly (v3.0.6)
- โ
Fixed installation issues - Reliable file copying and clear error messages (v3.0.2)
- โ
Enterprise-grade security - Process isolation, command validation, resource limits
- โ
Automatic context preservation every 30 minutes
- โ
Advanced project recovery from any state
- โ
Real-time compaction protection
- โ
Professional user experience with verbose feedback
- โ
Zero-configuration setup
- โ
Reliable automation
``bashGlobal installation (recommended)
npm install -g claude-code-automation
$3
`bash
Navigate to your project
cd your-projectInstall automation system
claude-code-automation installStart protection immediately (with verbose feedback)
code-automation --verbose preserveOr use npm scripts
npm run automation:preserve
`๐ Available Commands
$3
`bash
claude-code-automation install # Setup in current project
code-automation --verbose preserve # Preserve current context (with detailed feedback)
code-automation --verbose recover # Recover from backup (with detailed feedback)
code-automation --verbose analyze # Analyze project state (with detailed feedback)
preserve # Quick preserve (silent)
recover # Quick recover (silent)
analyze # Quick analyze (silent)
inject # Inject into existing project
`$3
`bash
code-automation --verbose [command] # Enable detailed security feedback
code-automation --quiet [command] # Suppress non-essential output
`$3
`bash
npm run automation:preserve # Preserve current state
npm run automation:recover # Recover from latest backup
npm run automation:analyze # Analyze project health
npm run automation:daily # Run full automation cycle
npm run automation:guard # Start anti-truncation guard
`๐ง Core Features
$3
Prevents context loss before it happens:
`bash
npm run automation:guard
`
- Monitors token usage in real-time
- Triggers preservation before limits
- Maintains conversation continuity$3
Predicts when compaction will occur:
- Analyzes conversation patterns
- Calculates risk scores
- Proactive preservation triggers$3
Continuous background protection:
- Auto-saves every 30 minutes
- Incremental state updates
- Zero performance impact$3
Comprehensive project restoration:
`bash
recover
Attempts to restore project state
`
- Reconstructs complete project state
- Restores all decisions and context
- Maintains development history๐ Enterprise Security (v3.0.0)
$3
- Process Isolation: Each project runs in isolated context
- Resource Limits: Max 5 processes, 512MB memory, 2-minute timeouts
- Command Whitelisting: Only npm, yarn, pnpm, node, git allowed
- Input Sanitization: Blocks dangerous patterns: ;, &&, ||, |, \`, $, >, <, &$3
`bash
Secure command execution with validation
code-automation --verbose preserve # Shows security decisionsProcess resource monitoring
code-automation analyze # Displays security statusSafe automation without global process hijacking
npm run automation:daily # Uses secure process management
`$3
- โ
Command Injection Prevention - All user input validated
- โ
Process Resource Limits - Prevents system overload
- โ
Path Traversal Protection - Secure file operations only
- โ
Process Cleanup - Automatic resource cleanup on exit
- โ
Timeout Enforcement - No runaway processes$3
- All process execution now goes through SecureProcessManager
- Stricter command validation may block some edge cases
- Process limits enforced (upgrade from unlimited processes)
- More restrictive input validation for enhanced security๐ Usage Examples
$3
`bash
Install globally
npm install -g claude-code-automationSetup new project
mkdir my-claude-project
cd my-claude-project
claude-code-automation installStart development with protection
npm run automation:preserve
`$3
`bash
If you lose context during development
recoverOr use NPM script
npm run automation:recoverVerify recovery
npm run automation:analyze
`$3
`bash
Start anti-truncation guard
npm run automation:guardRun daily maintenance
npm run automation:dailyCheck project health
npm run automation:analyze
`๐๏ธ Architecture
$3
- Context Preservation Engine - State capture and storage
- Auto Recovery System - Intelligent project reconstruction
- Live Preservation Engine - Real-time monitoring
- Anti-Truncation Guard - Proactive protection
- Compaction Risk Analyzer - Predictive analysis
- Development Session Tracker - Session continuity$3
`
your-project/
โโโ scripts/automation/ # Automation scripts
โโโ docs/automation/ # Generated documentation
โโโ docs/state/ # Project state snapshots
โโโ docs/recovery/ # Recovery instructions
โโโ package.json # Updated with scripts
`โ๏ธ Configuration
Configuration is automatic, but can be customized:
`json
{
"version": "1.0.0",
"enabled": true,
"features": {
"contextPreservation": true,
"antiTruncation": true,
"livePreservation": true,
"perfectRecovery": true,
"riskAnalysis": true,
"sessionTracking": true
},
"settings": {
"preservationInterval": 1800000,
"maxBackups": 50,
"compressionEnabled": true,
"verboseLogging": false
}
}
`๐งช Testing
`bash
Test installation
npm testVerify integrity
npm run verifyTest recovery system
code-automation recover --verify
`๐ Benefits
$3
- โ
Never lose progress again
- โ
Seamless session continuity
- โ
Instant project recovery
- โ
Zero maintenance required$3
- โ
Consistent project state
- โ
Reliable handoffs
- โ
Automated documentation
- โ
Reduced onboarding time๐ Upgrading
`bash
Upgrade globally
npm install -g claude-code-automation@latestUpdate existing projects
cd your-project
claude-code-automation install
`Latest features are automatically enabled!
๐ Troubleshooting
$3
Installation fails (Fixed in v3.0.6):
`bash
v3.0.6+ ensures all automation files are copied during installation
v3.0.2+ provides clear error messages if installation fails
claude-code-automation installIf you see "Failed to copy automation files":
1. Check npm permissions
2. Try reinstalling the package
npm uninstall -g claude-code-automation
npm install -g claude-code-automationAlternative: Use npx
npx claude-claude-code-automation install
`Files not copied to .automation/ directory:
`bash
v3.0.2+ shows detailed logging during installation
Look for these messages:
โ
Copied: context-preservation.js
โ
All 4 automation files copied successfully
If files are missing, check:
ls -la .automation/
Should contain: context-preservation.js, auto-recovery.js, etc.
`Recovery doesn't work:
`bash
Verify backup exists
ls docs/state/Force recovery
recover --forceCheck integrity
npm run verify
`Context still lost:
`bash
Enable verbose logging
npm run automation:preserve -- --verboseCheck risk analysis
npm run automation:analyze
`๐ Advanced Usage
$3
`javascript
// In your project
const preservation = require('claude-code-automation');
preservation.setInterval(15 60 1000); // 15 minutes
`$3
`yaml
.github/workflows/preserve.yml
name: Context Preservation
on: [push, pull_request]
jobs:
preserve:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install -g claude-code-automation
- run: preserve
``1. Fork the repository
2. Create a feature branch
3. Add tests for new functionality
4. Submit a pull request
MIT License - see LICENSE