Skip to main content
Analyze code architecture without modifying anything. This example shows how to use --skip for automation while keeping the analysis read-only.

The Script

From examples/analyze-code.md. Uses Sonnet for better code understanding.

How It Works

Model Selection: Sonnet

Sonnet is the balanced model tier:
  • Better than Haiku for code understanding and technical analysis
  • Cheaper than Opus - you don’t need the most capable model for analysis
  • Fast enough for real-time exploration
When to use each model:

The --skip Flag

This is shorthand for --dangerously-skip-permissions. It allows the AI to:
  • Read files without prompting you for each one
  • Use tools automatically
  • Explore the codebase freely
Wait, isn’t --skip dangerous?Yes, but only for write operations. This script’s prompt is read-only - it only asks for analysis. The AI won’t modify files unless your prompt tells it to.For true safety, use granular permissions:
See Permission Modes for production patterns.

The Prompt

The prompt is specific about what to analyze:
  • Main entry points - where execution starts
  • Key modules - important components
  • Data flow - how information moves through the system
The more specific your prompt, the better the analysis.

Running the Script

Analyze any codebase

The AI will:
  1. Explore the directory structure
  2. Read key files (package.json, main entry points, etc.)
  3. Analyze the architecture
  4. Summarize findings

Override the provider

Save output to file

Only the AI’s response is saved (not status messages).

Real-World Usage

Quick Project Overview

When joining a new codebase:
You now have a generated architecture document.

Compare Multiple Projects

CI/CD Documentation

Generate architecture docs automatically:

Customizing the Analysis

Focus on Specific Aspects

Security analysis:
Performance analysis:
Test coverage analysis:

Limit Scope

Why --skip Works Here

This script uses --skip even though it’s read-only because:
  1. Automation - No permission prompts when reading files
  2. Speed - The AI explores freely without asking
  3. Safe prompt - The prompt never asks to modify anything
The risk comes from the prompt, not the flag. A read-only prompt with --skip is safe.
For production scripts, prefer explicit tool allowlists:
This prevents accidents if someone modifies your prompt later.

Next Steps

Test Automation

Run commands and report results

Code Review

Automated security and quality scanning

CI/CD Integration

Run AIRun in GitHub Actions and GitLab CI

Scripting Guide

Permission modes and security patterns