claude-code-automation
v3.0.6
Published
π 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
Maintainers
Readme
Code Automation π
Universal 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.).
π Latest Features (v3.0.6)
π FIXED: Critical Installation Bug (v3.0.6)
- β Complete File Installation - Fixed missing anti-truncation-guard.js file during installation
- π οΈ All NPM Scripts Work - Users can now run all automation commands without module errors
- π― Immediate Fix - Resolves "Cannot find module" error for automation:guard command
π FIXED: Installation Issues (v3.0.2)
- β Reliable Installation - Fixed critical bug where automation files weren't copied
- π Enhanced Error Reporting - Clear feedback when installation fails
- π Detailed Logging - See exactly what's happening during installation
- β‘ Fail-Fast Behavior - Installation stops immediately with helpful error messages
π Enterprise Security (v3.0.0)
- π‘οΈ SecureProcessManager - Enterprise-grade process security system
- βοΈ Command Injection Prevention - Blocks dangerous shell patterns (
;,&&,||,|, etc.) - π Resource Limits - Process count (5 max), memory (512MB), timeout (2min) enforcement
- π Process Isolation - Secure project-level process management
- π― Command Whitelisting - Only allow safe npm, git, node operations
- π± Verbose Mode -
--verboseflag for detailed operation feedback
π§ Core Features
- π‘οΈ Anti-Truncation Guard - Prevents context truncation in real-time
- π Compaction Risk Analyzer - Predicts and prevents compaction events
- β‘ Live Preservation Engine - Continuous context monitoring
- π― Advanced Recovery System - Comprehensive project reconstruction
- π Development Session Tracker - Maintains session continuity
- π§ Enhanced Context Analysis - Deep project understanding
π― The Problem This Solves
Context 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
β The Solution
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
π Quick Start
Installation
# Global installation (recommended)
npm install -g claude-code-automation
# β οΈ IMPORTANT: NPM doesn't show post-install messages for global packages
# Run this command immediately after install:
welcome
# Or get detailed help
code-automation help
# Or local installation
npm install claude-code-automation --save-devSetup Your Project
# Navigate to your project
cd your-project
# Install automation system
claude-code-automation install
# Start protection immediately (with verbose feedback)
code-automation --verbose preserve
# Or use npm scripts
npm run automation:preserveπ Available Commands
CLI Commands (Global)
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π Security Options
code-automation --verbose [command] # Enable detailed security feedback
code-automation --quiet [command] # Suppress non-essential outputNPM Scripts (Project)
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
π‘οΈ Anti-Truncation Guard
Prevents context loss before it happens:
npm run automation:guard- Monitors token usage in real-time
- Triggers preservation before limits
- Maintains conversation continuity
π Compaction Risk Analyzer
Predicts when compaction will occur:
- Analyzes conversation patterns
- Calculates risk scores
- Proactive preservation triggers
β‘ Live Preservation Engine
Continuous background protection:
- Auto-saves every 30 minutes
- Incremental state updates
- Zero performance impact
π― Advanced Recovery System
Comprehensive project restoration:
recover
# Attempts to restore project state- Reconstructs complete project state
- Restores all decisions and context
- Maintains development history
π Enterprise Security (v3.0.0)
π‘οΈ SecureProcessManager
- 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:
;,&&,||,|,\``,$,>,<,&`
βοΈ Security Features
# Secure command execution with validation
code-automation --verbose preserve # Shows security decisions
# Process resource monitoring
code-automation analyze # Displays security status
# Safe automation without global process hijacking
npm run automation:daily # Uses secure process managementπ What's Protected
- β 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
π¨ Breaking Changes in v3.0.0
- 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
Basic Project Setup
# Install globally
npm install -g claude-code-automation
# Setup new project
mkdir my-claude-project
cd my-claude-project
claude-code-automation install
# Start development with protection
npm run automation:preserveRecovering Lost Context
# If you lose context during development
recover
# Or use NPM script
npm run automation:recover
# Verify recovery
npm run automation:analyzeContinuous Protection
# Start anti-truncation guard
npm run automation:guard
# Run daily maintenance
npm run automation:daily
# Check project health
npm run automation:analyzeποΈ Architecture
Core Components
- 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
File Structure
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:
{
"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
# Test installation
npm test
# Verify integrity
npm run verify
# Test recovery system
code-automation recover --verifyπ Benefits
For Developers
- β Never lose progress again
- β Seamless session continuity
- β Instant project recovery
- β Zero maintenance required
For Teams
- β Consistent project state
- β Reliable handoffs
- β Automated documentation
- β Reduced onboarding time
π Upgrading
# Upgrade globally
npm install -g claude-code-automation@latest
# Update existing projects
cd your-project
claude-code-automation installLatest features are automatically enabled!
π Troubleshooting
Common Issues
Installation fails (Fixed in v3.0.6):
# v3.0.6+ ensures all automation files are copied during installation
# v3.0.2+ provides clear error messages if installation fails
claude-code-automation install
# If 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-automation
# Alternative: Use npx
npx claude-claude-code-automation installFiles not copied to .automation/ directory:
# 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:
# Verify backup exists
ls docs/state/
# Force recovery
recover --force
# Check integrity
npm run verifyContext still lost:
# Enable verbose logging
npm run automation:preserve -- --verbose
# Check risk analysis
npm run automation:analyzeπ Advanced Usage
Custom Preservation Intervals
// In your project
const preservation = require('claude-code-automation');
preservation.setInterval(15 * 60 * 1000); // 15 minutesIntegration with CI/CD
# .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π€ Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
π License
MIT License - see LICENSE
