All About AI

Claude Code: The Complete Guide to Skills, Headless Mode, and AI Automation

Claude Code is Anthropic's terminal-based AI coding agent — a command-line tool that turns Claude into an autonomous developer with full filesystem and shell access. This guide walks through every Claude Code workflow I have shipped on this channel, from basic skills to nested parallel agents, with links to detailed deep-dives on each pattern.

If you only read one thing on this site about agentic AI, it should be this page. Claude Code sits at the center of almost every automation experiment I run.

What is Claude Code?

Claude Code is the official CLI from Anthropic that gives Claude (Sonnet 4.6 or Opus 4.7) direct, sandboxed access to your machine. Unlike a chat interface, Claude Code can read and edit files, run shell commands, execute scripts, and chain tools together to complete multi-step tasks autonomously.

The three primitives that matter most:

  1. Skills — reusable named workflows defined in .claude/skills/<name>/SKILL.md
  2. Headless mode — invoke Claude Code non-interactively with claude -p "<query>"
  3. Tools — the bash, file editing, and web fetch capabilities that ship with Claude Code, plus any MCP servers you add

Stack those three together and you can build everything from passive income loops to super-nested coding swarms.

How Claude Code Skills Work

A skill is just a markdown file. The frontmatter declares a name and a description, and the body contains the instructions Claude follows when the skill is invoked. The simplest skill looks like this:

---
name: hn-digest
description: Fetch top 5 Hacker News posts and email them
---

# /hn-digest

When invoked:
1. Run: python fetch_hn.py (saves news.json)
2. Run: python send_report.py (emails the saved JSON)
3. Confirm both ran without error

Save this at .claude/skills/hn-digest/SKILL.md, and you can call /hn-digest from inside Claude Code at any time. The skill just orchestrates other tools — the heavy lifting (fetching HN, sending email) lives in your supporting Python scripts.

I covered the full skill creation flow in my passive income post, and the design of the /post skill that auto-publishes blog posts from YouTube videos lives in this repo's .claude/skills/post/.

Headless Mode: claude -p

The -p flag is the unlock for automation. It puts Claude Code in non-interactive mode — pass a query, get one response, exit. Combined with skills, you get a primitive for unattended work:

claude -p "/hn-digest" --model claude-sonnet-4-6 --dangerously-skip-permissions

Wrap that in a bash while true; do ... ; sleep 60; done loop and you have a Claude Code worker that runs forever. This is the 3-part automation framework — cron + headless Claude + a browser tool — that powers most of my long-running setups.

Other useful headless flags:

I cover headless flags in detail in my headless AI agents post, including how I use them to put Claude Code agents in Minecraft as teammates.

Real Use Cases I Have Shipped

Here are the actual production-grade Claude Code workflows running on my Mac mini right now:

Passive income loops

Multiple while-true loops, each running a different revenue skill. The Kalshi bug bounty monitor earns $100-$200/week. The full pattern is documented in Claude Code passive income setup.

iOS app pipeline

A 5-stage Claude Code pipeline that researches app ideas, writes Swift, tests in the Xcode simulator, and submits to App Store Connect — all autonomously. Real revenue: $275 over 13 days. See make money automating iOS apps and the 10-day update.

Polymarket trading bot

Claude Code drives a browser session on Polymarket, places bets in the 5-minute Bitcoin up/down market, and runs autoresearch loops to evolve the strategy. See predictions market trading and Karpathy's autoresearch on the bot.

Autoresearch security tester

An autoresearch loop pointed at my own website, tasked with breaching it as a white-hat exercise. After 16 experiments across 12 attack categories, only one minor finding. See autoresearch Claude Code hacker.

Drawing experiments

Goal + tool + evaluator: Claude Code draws in JS Paint, iterating until the similarity score passes. See can Claude Code learn to draw.

Advanced Patterns

Parallel sub-agents

Spawn multiple Claude Code instances in parallel, each handling a slice of work. For browser tasks this is a 4-7x speedup. Documented in parallel AI agent browser automation.

Super-nested Claude Code

One Opus controller orchestrates 6+ child Claude Code instances in tmux, each working on a different file or subsystem. You write goals; the controller writes prompts. Open-sourced at github.com/Ejae-dev/supervibes. Full walkthrough in super-nested Claude Code is vibecoding on steroids.

Twitch agent that controls Claude Code on stream

A Claude Code controller that takes Twitch chat requests, dispatches build prompts to nested Claude Code instances, and streams the entire thing live via FFmpeg. See Claude Code AI agent on Twitch.

Long-running autonomous operation

One agent ran continuously for 504 hours straight on a Mac mini, posting to X, publishing YouTube videos, running a Stripe-backed store, and browsing the web — see the 504-hour experiment.

Comparison: Claude Code vs Alternatives

You can run similar agentic patterns with Codex (codex exec), opencode (opencode run), or self-hosted OpenClaw / NeMoClaw. My take after using all of them:

For most of my work, Claude Code is the default and I switch to alternatives only for specific reasons (cost, model preference, terms-of-service edge cases).

Getting Started With Claude Code

If you are new to Claude Code, follow this order:

  1. Install the CLI from Anthropic's docs and authenticate with your Claude Pro/Max subscription.
  2. Run claude in a fresh project directory and ask it to do something simple — list files, read a file, run a script.
  3. Read the 3-part automation framework to understand the cron + headless + browser pattern.
  4. Build your first skill following the example in passive income setup.
  5. Add a browser tool — install Surfagent via npm install -g surfagent.
  6. Pick one experiment from this site and reproduce it.

Resources

FAQ

How much does Claude Code cost?

Claude Code is included with Claude Pro and Claude Max subscriptions (~$20 and ~$200/month respectively at the time of writing) — usage limits scale with the plan. There is no free tier; the Max plan's flat fee makes 24/7 automation economically attractive.

Can Claude Code use other models like GPT-5 or Gemini?

Claude Code itself runs only Claude (Sonnet 4.6 or Opus 4.7). For other models, use Codex exec (for OpenAI), opencode (any OpenAI-compatible endpoint), or self-hosted OpenClaw / NeMoClaw.

How is Claude Code different from Cursor or Cline?

Cursor is an IDE with AI assistance; Cline is a VS Code extension; Claude Code is a standalone CLI agent designed for autonomous, headless, long-running tasks. They overlap in capability but Claude Code is the only one with first-class headless mode and skill files.

Does Claude Code work on Windows?

Yes — natively on macOS and Linux, and on Windows via WSL. The headless and skill features work identically across platforms; some tmux-based patterns (super-nested Claude Code) require macOS or WSL with tmux installed.

What does Claude Code do when a tool call fails?

Claude Code reads the error, reasons about the cause, and attempts a different approach — often building a small recovery script on the fly. For long-running automation, you can wrap it in retry logic and circuit breakers via the bash loop layer.

Can Claude Code be used at work, or just for hobby projects?

Claude Code is widely used in commercial development; Anthropic's enterprise plans add SOC 2 compliance, SSO, and team management. Production use is well-supported as long as your data-handling rules permit sending source code to Anthropic's API.