Orchestrate multiple Claude Code sessions and intelligently aggregate approved commands across projects.
- Session Discovery: List all active Claude Code sessions grouped by project and worktree
- Command Aggregation: Extract allowed/denied commands from project settings
- Intelligent Grouping: Use Claude Haiku to safely group similar commands with wildcards
- Safety Validation: Never wildcard dangerous commands (rm, --force, etc.)
- User Settings Sync: Apply approved commands to
~/.claude/settings.json - History Tracking: Maintain markdown log of all command approvals
# Install dependencies
pnpm install
# Make CLI executable (optional - not needed, you can run all the same scripts using `pnpm orchestrator {command}`)
chmod +x src/cli.tspnpm claude-commands listShows all Claude Code sessions grouped by project, including:
- Project paths
- Git branches (worktrees)
- Number of sessions
- Last activity time
pnpm claude-commands collectThis will:
- Discover all active sessions (last 7 days or since last run)
- Extract commands from project
.claude/settings.jsonandsettings.local.json - Use Claude Haiku to intelligently group similar safe commands
- Generate a review file (e.g.,
review-2025-10-23-183045.json)
pnpm claude-commands review review-2025-10-23-183045.jsonInteractive controls:
A- Approve current itemD- Deny current itemS- Skip (leave as pending)N- Next itemP- Previous itemQ- Save and quit
# Apply approved commands to ~/.claude/settings.json
pnpm claude-commands apply review-2025-10-23-183045.jsonThis will:
- Read the review file
- Extract approved patterns and commands
- Backup
~/.claude/settings.json - Merge approved commands into user settings
- Append to
history/command-approvals.md
The orchestrator uses a comprehensive safety framework to prevent dangerous wildcards:
- Development commands:
poetry run:*,npm run:* - Non-destructive git:
git checkout:*,git add:* - Testing:
pytest:*,jest:* - Build tools:
npm build:*,cargo build:*
- Publishing:
git commit:*,git push:*(without --force) - Package installation:
npm install:*,pip install:*
- Destructive operations:
rm,del,--force,--hard - Permission changes:
chmod,chown,sudo - Network operations:
curl,wget - Domain access:
WebFetch(domain:*)- keep specific - Sensitive paths:
Read(//home/**),Read(//etc/**)
- Daily/Weekly: Run
orchestrator collectto gather commands from active sessions - Review: Edit the generated review file, approve/deny commands
- Apply: Run
orchestrator apply review-*.jsonto update user settings - Benefit: New Claude Code sessions automatically allow approved commands
{
"date": "2025-10-23T18:30:00.000Z",
"groupings": [
{
"pattern": "Bash(poetry run:*)",
"matches": ["Bash(poetry run test)", "Bash(poetry run lint)"],
"reasoning": "Safe: All poetry run commands execute project-defined scripts",
"confidence": "high",
"safetyCategory": "SAFE_TO_WILDCARD",
"approved": true // ← Edit this
}
],
"ungrouped": [
{
"command": "Bash(rm -rf temp)",
"reasoning": "Dangerous: Destructive file deletion",
"safetyCategory": "NEVER_WILDCARD",
"approved": false // ← Edit this
}
]
}src/
├── cli.ts # Main CLI entry point
├── session-discovery.ts # Parse ~/.claude/projects JSONL files
├── command-aggregator.ts # Extract from project settings
├── grouping-agent.ts # Use Haiku to group commands
├── settings-manager.ts # Read/write ~/.claude/settings.json
├── history-tracker.ts # Maintain approval history
└── types.ts # TypeScript types
- Node.js 22+
- Claude Code CLI installed and authenticated
- Active Claude Code sessions with project settings
MIT