Skip to content

20 Real-World CLI Scenarios

You have a deadline in two days, a codebase you barely understand, and a feature request that touches twelve files across three services. You could spend the first day just reading code. Or you could open a terminal, type claude, and start shipping.

These 20 lessons are built from real development workflows — the kind where things break, requirements change, and “it works on my machine” is never good enough. Each one gives you a repeatable process you can use starting today. What separates a developer who uses Claude Code from one who is productive with it is workflow design, so the lessons are followed by the patterns underneath them: when to use plan mode, how to structure batch operations, when to delegate to subagents, and how to chain CLI commands into automated pipelines.

What you’ll walk away with from these 20 CLI lessons

Section titled “What you’ll walk away with from these 20 CLI lessons”
  • A complete CLI-first development workflow from project scaffolding through production deployment
  • Copy-paste prompts for every phase of the development lifecycle
  • Debugging, testing, and refactoring patterns that work on real codebases, not toy examples
  • Automation techniques that let Claude Code handle the repetitive work while you make the decisions

Start here. These four lessons take you from an empty directory to production-ready code.

Project Initialization

Bootstrap full-stack projects in minutes. Configure CLAUDE.md, set up tooling, and generate project scaffolding from a single terminal session. Start Building

Codebase Analysis

Onboard to a 500K-line monorepo without reading every file. Use sub-agents to map architecture, trace data flows, and find the code that matters. Explore Codebases

Feature Planning

Turn vague product requirements into detailed implementation plans using Plan Mode and extended thinking. Get the architecture right before writing a line of code. Plan Features

Implementation

Go from plan to working code. Learn the explore-plan-implement-commit cycle that keeps Claude on track across multi-file changes. Write Code

Daily development: the workflows you reach for every day

Section titled “Daily development: the workflows you reach for every day”

These are the bread-and-butter patterns. The workflows you reach for at 10 AM and again at 4 PM.

Debugging

Pipe error logs directly into Claude, trace execution paths across services, and fix bugs in minutes that used to take hours. Includes headless mode for automated error triage. Fix Bugs

Testing

Generate test suites that match your existing patterns. Use the red-green-refactor loop with Claude running tests after every change. Coverage gaps become obvious. Write Tests

Refactoring

Rename across 200 files. Migrate from callbacks to async/await. Extract shared modules. Fan out with headless mode for large-scale changes that land cleanly. Refactor Code

Documentation

Generate JSDoc, OpenAPI specs, and architecture docs from your actual codebase. Set up hooks that keep docs in sync with every file edit. Document Code

Backend development: APIs, databases, and infrastructure

Section titled “Backend development: APIs, databases, and infrastructure”

Server-side workflows where Claude Code’s CLI-native approach really shines.

API Development

Scaffold REST and GraphQL endpoints with validation, auth middleware, and error handling. Test with curl without leaving Claude’s session. Build APIs

Database Work

Design schemas, generate migrations, write complex queries, and seed test data. Use headless mode to audit query performance across your entire codebase. Work with Data

Deployment

Dockerize applications, configure CI/CD pipelines, and automate production deployments — all from the terminal. Deploy Apps

Monitoring

Set up structured logging, health checks, and alerting. Pipe production logs into Claude for real-time anomaly detection. Monitor Systems

Advanced: architecture, security, and scale

Section titled “Advanced: architecture, security, and scale”

For the senior engineers who want to push Claude Code to its limits.

Security Audit

Scan for vulnerabilities, audit dependencies, and generate security reports. Use sub-agents to review code from multiple security perspectives simultaneously. Secure Code

Performance

Profile bottlenecks, optimize database queries, and benchmark changes. Claude reads flame graphs and heap snapshots so you can focus on the fix. Optimize Performance

Migrations

Handle zero-downtime database migrations, framework upgrades, and API version transitions. Fan out across files for large-scale transformations. Migrate Systems

Integrations

Connect MCP servers, configure skills, and build custom sub-agents. Extend Claude Code to fit your team’s exact workflow. Integrate Services

Stop doing things twice. These lessons turn manual workflows into repeatable automation.

Task Automation

Build hooks for auto-formatting, headless scripts for batch operations, and custom skills that encode your team’s workflows. Automate Tasks

CI/CD Pipelines

Run Claude Code in GitHub Actions for automated code review, test generation, and PR creation. Headless mode makes it scriptable. Configure Pipelines

Containerization

Generate Dockerfiles, compose configurations, and Kubernetes manifests. Debug container issues by piping logs directly into Claude. Containerize Apps

System Architecture

Use extended thinking for architectural decisions. Have Claude interview you about requirements, then generate implementation specs. Design Systems

The workflow patterns underneath the lessons

Section titled “The workflow patterns underneath the lessons”

The lessons above solve a scenario end to end. These articles isolate the patterns that recur across all twenty — the ones experienced Claude Code users reach for every day, whatever they happen to be building.

Terminal Mastery

tmux integration, multi-session workflows, shell history patterns, and terminal multiplexer configurations optimized for Claude Code.

Master terminal workflows

Prompt Engineering

The difference between prompts that work and prompts that produce exactly what you need. Structured prompting, plan mode, thinking keywords, and context priming.

Write better prompts

Batch Operations

Rename 200 files, update 50 imports, migrate an API version across your monorepo. Patterns for large-scale code changes that would take hours manually.

Scale with batch operations

Script Automation

Turn repeating Claude Code workflows into scripts. Print mode pipelines, cron jobs, pre-commit hooks, and headless automation.

Automate with scripts

IDE + CLI Coordination

Use Claude Code alongside VS Code, Cursor, or JetBrains. Split-screen workflows, shared context, and patterns that leverage both interfaces.

Coordinate IDE and CLI

Debugging Workflows

Systematic debugging from the terminal. Error trace analysis, bisection strategies, log parsing, and the prompts that find root causes fastest.

Debug effectively

Review Automation

Automated code reviews via CLI. Pre-commit review, PR analysis, dependency auditing, and quality gates that run before human reviewers see the code.

Automate code reviews

Deployment Patterns

Pre-deploy validation, changelog generation, release note creation, and rollback assistance. Claude Code as your deployment copilot.

Streamline deployments

Efficiency Hacks

The small techniques that add up to hours saved per week. Output format tricks, context management shortcuts, and workflow optimizations.

Save time every day

Start with Project Initialization to get comfortable with the basics: launching sessions, writing prompts, and understanding how Claude reads and modifies your code. Then move through Codebase Analysis, Feature Planning, and Implementation in order. Read Prompt Engineering alongside them to build the foundation, then Terminal Mastery for your daily setup.

Jump to the lesson that matches your current bottleneck. Most experienced users find the biggest wins in Refactoring (fan-out patterns for large changes), Testing (automated coverage gap detection), and Automation (hooks and headless mode). On the pattern side, go straight to Batch Operations or Script Automation.

Focus on CI/CD Pipelines and Security Audit for org-wide impact. The headless mode patterns in those lessons let you embed Claude Code into existing team workflows without requiring everyone to change how they work.