Skip to main content

Claude Code Examples Hub — Automation, MCP, Hooks, and Headless Mode

A directory-style hub for everything you can do with Claude Code, organized by type — headless automation, hooks, subagents, and MCP — with the core command for each linked guide.

By
🌐 This article was machine-translated and may contain inaccuracies. Read the Korean original if in doubt.

Claude Code — an AI agent (a program that reads context and decides what to do on its own) that reads and edits code from your terminal — naturally raises the question "what else can I actually do with this?" This article is a directory-style hub that organizes the hands-on example articles already published on usingclaude.com. It invents nothing new; it groups the existing, verified guides into six buckets — headless automation, hooks, workflow control, commands, real-world workflows, and MCP — and surfaces each guide's core command up front. Five minutes is enough to get the full map.

🟢 Model references match the current lineup · model notice · Fable subscription
🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.

Fable 5 and 5.1 subscription (updated September 7, 2026): Claude Fable 5.1, released September 1, 2026, is the current Fable model and Fable 5 is now legacy. Plan terms are the same for both — Max and Team Premium plans include Fable at up to 50% of the weekly usage limit; Pro and Team Standard use usage credits (

🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
0/M input, $50/M output tokens). The one-time
🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
00 credit applied only to the Fable 5 transition and is not offered for 5.1. Some coding and debugging requests may be answered by an Opus model due to a security classifier (both models). See the Fable 5.1 guide and the Fable 5 availability guide for details.

Claude Code Examples Headless automation claude -p, GitHub Hooks auto-run on events Workflow control subagents, plan, advisor Commands & shortcuts slash commands, keys Real-world workflows explore, debug, PR MCP integration connect external tools

What can you do with this hub

Skimming this hub gives you a map of what's actually possible with Claude Code — automation, rules, MCP integrations — in about five minutes. Every entry links to a full guide already published on usingclaude.com; this page itself is just an index that pulls out each guide's core command. If you haven't installed Claude Code yet, start with the Claude Code install guide to set up a CLI (command-line interface — controlling a program by typing commands instead of clicking) environment first.

Quick term glossary

  • Headless — running with no interactive screen: one command in, the result out
  • Hooks — user-defined rules that run automatically at specific points in a session
  • Subagent — a specialized AI with its own context, dedicated to one specific task
  • MCP (Model Context Protocol) — a standard for connecting AI to external tools and data
  • CI (Continuous Integration) — a pipeline that automatically builds and tests code changes

Automating scripts and CI with headless mode

The fastest way into Claude Code automation is headless mode (claude -p), which runs with no interactive screen. The two guides below cover calling Claude from a script or CI pipeline, and letting @claude mentions on GitHub PRs and issues trigger automated work.

ExampleCore commandWhat it does
Headless mode automationclaude -p "prompt", --output-format json, -cPrints a response and exits with no interactive session — used for scripts and server automation
GitHub integration/install-github-app, @claude mentionAn @claude mention on a PR or issue triggers automated analysis and fixes via GitHub Actions
claude -p headless run → PostToolUse hook auto format/test → gh pr create open PR → GitHub Actions @claude review

This flow chains headless execution, a hook, PR creation, and GitHub integration into one example. Each step comes straight from the two guides above and the hooks section below — you don't need to build the whole chain at once, and can adopt just the steps you need.

Automating rules with hooks

A hook is a user-defined rule that runs automatically at a specific point in a session, enforcing guardrails like auto-formatting, blocking dangerous commands, or gating tests without anyone having to remember to do it manually. Hooks are made of three parts — event, matcher, and action — configured interactively with /hooks or persisted in .claude/settings.json (project) or ~/.claude/settings.json (global).

EventWhen it firesTypical use
PreToolUseRight before a tool runsBlock a dangerous command (exit code 2 stops the tool call)
PostToolUseAfter a tool finishesAuto-format, run tests
StopWhen the session stopsCleanup, logging
SessionStart / SessionEndSession start/endEnvironment setup and teardown

For matcher syntax (filters like "Edit|Write" or "Bash") and the four handler types (command, prompt, agent, http), see the full Claude Code hooks guide.

Subagents, Plan mode, and Advisor — controlling the workflow

To break up a large task safely, you can combine three tools: subagents to isolate side work, Plan mode to review a plan before any edit happens, and Advisor to call in a stronger model only at the moment you're stuck.

ExampleCore commandWhat it does
Subagents/agentsCreate a specialized AI dedicated to one task, keeping bulk output like test logs out of the main conversation
Plan modeShift+Tab or claude --permission-mode planDraft a plan before any file edit, then proceed only after approval
Advisor/advisorLet a fast model consult a stronger model when it gets stuck

Learning slash commands and shortcuts fast

If you use Claude Code daily, learning the / slash commands and a handful of keyboard shortcuts noticeably speeds up your work. Save a frequently used prompt as a markdown file in .claude/commands/ and its filename becomes a custom command.

TypeRepresentative examplesWhat it does
Built-in slash commands/clear, /compact, /model, /initReset the conversation, compact context, pick a model, generate CLAUDE.md
Session shortcutsEsc, Shift+Tab, Ctrl+L, ↑Interrupt work, cycle permission mode, redraw the screen, recall the previous input
Creating a custom command.claude/commands/name.mdThe saved filename becomes the /name command

See the full lists in the slash commands guide and the shortcuts cheat sheet.

Five real-world workflows — from exploring code to opening a PR

Day-to-day development work with Claude Code breaks down into five workflows: exploring code, debugging, refactoring, writing tests, and creating a PR. The shared principle across all five is to read and plan before making a change.

WorkflowCore command/featureWhat it does
Explore code@file-pathRead-only look at unfamiliar code or where a feature lives
DebugAsk with the error message attachedTrace the root cause and fix it in the same request
RefactorAsk for incremental stepsMove legacy patterns to modern ones step by step
Write tests@file plus style guidanceGenerate tests that match existing style and cover edge cases
Create a PRgh pr create, --from-pr <number>Turn changes into a PR and resume a previous PR session

For concrete prompt examples and tips on compacting context with /compact, see Claude Code use cases.

Connecting external tools with MCP

MCP (Model Context Protocol) is a standard for connecting AI to external tools and data, often compared to "a USB-C port for AI." Attaching an MCP server to Claude Code lets you work directly with systems like GitHub, Slack, Notion, or a database from inside the conversation. MCP isn't part of the examples category, but it's the area most often combined with automation and headless work in practice, so this hub includes its flagship guides too.

ExampleCore commandWhat it does
What is MCP?—Explains the concept and why a standard protocol matters
Connecting an MCP serverclaude mcp add --transport http name URL, claude mcp listAdd, list, and remove MCP servers at local, project, or user scope
Recommended MCP servers—A curated list of servers by use case — GitHub, Slack, Notion, PostgreSQL, and more

Detailed setup guides for individual servers — GitHub, Slack, Notion, PostgreSQL, Playwright, Filesystem, Figma, and more — live in the MCP category.

Frequently asked questions

Q. Where should I start with Claude Code examples?
Start with headless mode and slash commands. Try non-interactive automation with claude -p first, get comfortable with basics like /clear and /compact, then branch out into hooks, subagents, and MCP.

Q. What's the difference between hooks and subagents?
A hook is a deterministic action that runs automatically at a set point according to a fixed rule, while a subagent is a specialized AI that takes on a delegated task and makes its own judgment calls in an independent context.

Q. What do I need to use GitHub Actions automation?
Run /install-github-app to install the GitHub app, then add ANTHROPIC_API_KEY as a repository secret. Never put the key value directly in code or a document — keep it only as a GitHub Secret.

Q. Does this hub cover MCP too?
Yes. MCP lives in its own category, but since it's so often paired with automation and headless work, this hub includes three flagship guides. Server-specific setup guides are in the MCP category for more depth.

This hub adds no new examples — it re-maps the existing hands-on guides by type. Follow any link in the tables above for the full commands and configuration files.

Was this helpful?

Keep reading