
command-executor
by d-oit
๐ Intelligent command verification system for documentation with git diff-based cache invalidation. Zero-token operation, cross-platform CLI tool that discovers and validates commands in markdown files with 90%+ cache hit rates. Built for modern JavaScript/Node.js projects with comprehensive testing and self-learning capabilities.
SKILL.md
name: command-executor version: "0.2.0" description: Executes safe commands and captures real output to extend command-verify functionality. Only runs when explicitly requested. Use when asked to actually run commands, execute commands, test if commands work, or verify commands actually execute. author: "Claude Code" categories: ["execution", "testing", "automation", "validation"] keywords: ["command", "execution", "testing", "output", "performance", "safety"] allowed-tools: Read,Glob,Bash,AskUserQuestion
Command Executor
Overview
This skill extends the command-verify skill to actually execute safe commands and capture real output. It provides execution capabilities with safety checks and output capture.
When to Use
Invoke this skill when the user asks to:
- "Actually run the commands"
- "Execute the commands"
- "Test if commands work"
- "Verify commands actually execute"
- "Run the safe commands and show output"
Safety First
NEVER auto-execute dangerous commands. Always follow these safety rules:
Commands to NEVER Execute:
rm -rf(destructive deletion)git push --force(destructive git operation)npm run clean/clear/reset(destructive cleanup)drop database(database destruction)- Any command with
--deleteor--forceflags truncateoperations
Commands Requiring Confirmation:
npm install(modifies node_modules)npm run format(modifies source files)- Commands with
--forceflags - Any command modifying files
Commands Safe to Auto-Execute:
npm run buildnpm run testnpm run lintnpm run typecheckgit statusnode --version- Read-only operations
How It Works
1. Pre-Flight Checks
Before executing any commands:
- Check git status (ensure working directory is clean)
- Check git branch (warn if on main/master)
- Check for uncommitted changes (ask before running)
2. Execution Plan
Always show the user what will be executed:
Execution Plan:
โ npm run build (safe, will execute)
โ npm run test (safe, will execute)
? npm install (conditional, will ask)
โ rm -rf node_modules (dangerous, will skip)
Continue? [y/N]
Use the AskUserQuestion tool to get confirmation.
3. Command Execution
Execute commands sequentially (not in parallel for safety):
- Capture stdout, stderr, exit code, duration
- Stop on first failure (fail-fast)
- Log all executions to audit log
4. Output Capture
For each executed command, capture:
- stdout: Standard output
- stderr: Error output
- exit code: Success/failure status
- duration: Execution time in milliseconds
- timestamp: When it was executed
Store in .cache/command-validations/executions/<hash>.json:
{
"command": "npm run build",
"executedAt": "2025-10-29T10:00:00Z",
"duration": 2341,
"exitCode": 0,
"stdout": "Successfully compiled 42 files",
"stderr": "",
"success": true,
"commit": "a1b2c3d"
}
5. Performance Comparison
Compare execution results with previous runs to detect:
- Performance regressions: Duration > previous * 1.5
- New errors: stderr differs from previous
- Output changes: Significant stdout differences
Instructions for Claude
When this skill is invoked:
-
Pre-Flight Phase
- Run
git statusto check working directory state - Run
git branchto identify current branch - Warn if on main/master
- Check for uncommitted changes
- Run
-
Discovery Phase
- Use command-verify skill to discover all commands
- Categorize each command (safe/conditional/dangerous)
-
Planning Phase
- Create execution plan showing which commands will run
- Use AskUserQuestion tool to get confirmation
- Show clear indicators (โ safe, ? conditional, โ dangerous)
-
Execution Phase
- Execute commands sequentially using Bash tool
- For each command:
- Capture full output (stdout/stderr)
- Measure execution time
- Record exit code
- Save to cache
- Stop on first failure
-
Reporting Phase
- Show execution results:
Execution Report: โ npm run build (2.3s) Output: Successfully compiled 42 files โ npm run test (4.5s) Output: 87 tests passed Summary: - Executed: 2/4 commands - Success: 2/2 - Duration: 6.8s - Performance: โ No regressions detected - Highlight any performance regressions
- Show any new errors or warnings
- Show execution results:
-
Cache Update Phase
- Save execution results to
.cache/command-validations/executions/ - Update audit log at
.cache/command-validations/audit.log - Format:
[timestamp] command - STATUS - duration
- Save execution results to
Error Handling
- Command fails: Capture error, report clearly, continue if user approves
- Timeout: Kill process after 5 minutes, mark as timeout
- Permission denied: Skip command, suggest permission fix
- Missing dependencies: Provide installation instructions
Performance Expectations
- Discovery: ~100ms (reuse command-verify)
- Planning: ~50ms (categorization)
- Execution: Depends on commands
- Reporting: ~50ms
Safety Features
Dry Run Mode
Show what would be executed without actually running:
Dry Run - Would execute:
โ npm run build
โ npm run test
Would skip:
โ rm -rf node_modules (dangerous)
Audit Log
All executions logged to .cache/command-validations/audit.log:
[2025-10-29 10:00:00] npm run build - SUCCESS - 2.3s
[2025-10-29 10:00:03] npm run test - SUCCESS - 4.5s
[2025-10-29 10:00:08] npm install - SKIPPED - user declined
Confirmation Required For
- First time executing a command
- Commands in dangerous category
- Commands on production branch
- Commands with side effects
Integration
This skill works alongside command-verify:
- command-verify discovers and validates commands
- command-executor actually runs safe ones
- Both share the same cache structure
- Results enhance future validations
Example Usage
User: "Verify and execute the safe commands"
Claude's actions:
- Invoke command-verify to discover commands
- Categorize commands (safe/conditional/dangerous)
- Show execution plan to user
- Get user confirmation via AskUserQuestion
- Execute safe commands using Bash
- Capture and report results
- Update cache with execution data
Output:
โ Found 15 commands
โ 8 safe, 5 conditional, 2 dangerous
Execution Plan:
โ npm run build
โ npm run test
โ npm run lint
Continue? y
Executing...
โ npm run build (2.3s) - Success
โ npm run test (4.5s) - Success
โ npm run lint (1.2s) - Success
All commands executed successfully!
No performance regressions detected.
Score
Total Score
Based on repository quality metrics
SKILL.mdใใกใคใซใๅซใพใใฆใใ
ใฉใคใปใณในใ่จญๅฎใใใฆใใ
100ๆๅญไปฅไธใฎ่ชฌๆใใใ
GitHub Stars 100ไปฅไธ
3ใถๆไปฅๅ ใซๆดๆฐ
10ๅไปฅไธใใฉใผใฏใใใฆใใ
ใชใผใใณIssueใ50ๆชๆบ
ใใญใฐใฉใใณใฐ่จ่ชใ่จญๅฎใใใฆใใ
1ใคไปฅไธใฎใฟใฐใ่จญๅฎใใใฆใใ
Reviews
Reviews coming soon


