Skip to main content
Automate test execution and failure analysis. This example shows how to use --skip to run commands and report results.

The Script

From examples/run-tests.md. The AI detects your test framework automatically.

How It Works

Running Commands: --skip

Shorthand for --dangerously-skip-permissions. This allows the AI to:
  • Run shell commands (npm test, pytest, cargo test, etc.)
  • Read test output without prompting
  • Analyze failures by reading source files
Without --skip, the AI would prompt you for permission before each command.
--skip gives full system access. Only use it for:
  • Trusted scripts you wrote yourself
  • Trusted directories you control
  • CI/CD environments with proper sandboxing
For granular control, use --allowedTools instead:

Automatic Framework Detection

The AI automatically detects your test framework:
  • JavaScript/TypeScript: npm test, jest, vitest, mocha
  • Python: pytest, unittest
  • Rust: cargo test
  • Go: go test
  • Ruby: rspec, minitest
  • Shell scripts in test/ directories
It looks at package.json, Cargo.toml, go.mod, etc. to figure out what to run.

Intelligent Failure Analysis

When tests fail, the AI:
  1. Reads the error output to understand what went wrong
  2. Examines source files to find the root cause
  3. Explains the issue in plain English
  4. Suggests fixes (but doesn’t apply them unless prompted)

Running the Script

Basic Usage

Output:

Save Report to File

Only the AI’s analysis is saved (status messages go to stderr).

Override Model or Provider

Real-World Usage

Pre-Commit Hook

Run tests before each commit:

CI/CD Integration

GitHub Actions:
GitLab CI:

Nightly Test Analysis

Run comprehensive test analysis overnight:

Fix Tests Automatically

This modifies code. Only use in development, never in CI without review.

Customizing the Analysis

Focus on Specific Test Types

Unit tests only:
Integration tests with setup:

Performance Testing

Coverage Analysis

Combining with Live Output

For long test suites, add --live to see progress:
Now you’ll see updates as tests run instead of waiting for everything to complete.

Security Best Practices

Use Granular Permissions

Instead of --skip, specify exactly what’s allowed:
This prevents accidental modifications even if your prompt changes.

CI/CD Sandboxing

In CI/CD, run inside containers:
If the AI does something unexpected, it only affects the container.

Limit Test Commands

Explicitly list which test commands are allowed.

Next Steps

Live Streaming

See test progress in real-time

CI/CD Guide

Complete CI/CD integration patterns

Code Review

Automated code review workflows

Security

Security best practices for automation