← Back to Blogs

How to Get Started with Agentic Coding: Intermediate

25 min read
Claude CodeAgentic AITutorialIntermediate

You've got the basics down. You can install Claude Code, talk to it, and build projects through conversation. Now it's time to unlock the features that separate casual users from power users.

This guide covers the advanced building blocks: sub-agents, hooks, skills, MCP servers, configuration files, and plugins. By the end, you'll understand how to customize Claude Code to fit your exact workflow.

Part 1: Understanding the Architecture

Before diving into features, let's understand how Claude Code is structured:

text
+-----------------------------------------------------------------------------+
|                           CLAUDE CODE ARCHITECTURE                          |
+-----------------------------------------------------------------------------+
|                                                                             |
|    +----------------------------------------------------------------+       |
|    |                     YOUR TERMINAL                              |       |
|    |                                                                |       |
|    |   $ claude                                                     |       |
|    |                                                                |       |
|    |   +--------------------------------------------------------+   |       |
|    |   |                 MAIN AGENT (Claude)                    |   |       |
|    |   |                                                        |   |       |
|    |   |  +----------+  +----------+  +----------+              |   |       |
|    |   |  |Sub-Agent |  |Sub-Agent |  |Sub-Agent |              |   |       |
|    |   |  |(Explore) |  |(Plan)    |  |(Custom)  |              |   |       |
|    |   |  +----------+  +----------+  +----------+              |   |       |
|    |   |                                                        |   |       |
|    |   +--------------------------------------------------------+   |       |
|    |                              |                                  |       |
|    |                              v                                  |       |
|    |   +--------------------------------------------------------+   |       |
|    |   |                    TOOLS & EXTENSIONS                  |   |       |
|    |   |                                                        |   |       |
|    |   |  +--------+ +--------+ +--------+ +--------+           |   |       |
|    |   |  | Hooks  | | Skills | |  MCP   | |Plugins |           |   |       |
|    |   |  |        | |        | |Servers | |        |           |   |       |
|    |   |  +--------+ +--------+ +--------+ +--------+           |   |       |
|    |   |                                                        |   |       |
|    |   +--------------------------------------------------------+   |       |
|    |                              |                                  |       |
|    |                              v                                  |       |
|    |   +--------------------------------------------------------+   |       |
|    |   |                   CONFIGURATION                        |   |       |
|    |   |                                                        |   |       |
|    |   |  ~/.claude/CLAUDE.md         (User-level)              |   |       |
|    |   |  ./CLAUDE.md                 (Project-level)           |   |       |
|    |   |  ~/.claude/settings.json     (User settings)           |   |       |
|    |   |  ./.claude/settings.json     (Project settings)        |   |       |
|    |   |                                                        |   |       |
|    |   +--------------------------------------------------------+   |       |
|    |                                                                |       |
|    +----------------------------------------------------------------+       |
|                                                                             |
+-----------------------------------------------------------------------------+

Each layer adds capabilities. Let's explore them one by one.

Part 2: Sub-Agents, Your Specialized Team

What Are Sub-Agents?

Sub-agents are specialized Claude instances that the main agent can delegate tasks to. Instead of one generalist doing everything, you get specialists.

text
+-----------------------------------------------------------------------------+
|                         SUB-AGENT DELEGATION                                |
+-----------------------------------------------------------------------------+
|                                                                             |
|    You: "Review this code and add tests"                                    |
|                              |                                              |
|                              v                                              |
|                    +-----------------+                                      |
|                    |   Main Agent    |                                      |
|                    |   (Orchestrator)|                                      |
|                    +--------+--------+                                      |
|                             |                                               |
|              +--------------+--------------+                                |
|              |              |              |                                |
|              v              v              v                                |
|     +--------------+ +------------+ +-------------+                         |
|     | Code Reviewer| |Test Writer | |  Explore    |                         |
|     |  Sub-Agent   | | Sub-Agent  | |  Sub-Agent  |                         |
|     |              | |            | |             |                         |
|     | Own context  | |Own context | | Own context |                         |
|     | Own tools    | |Own tools   | | Read-only   |                         |
|     +------+-------+ +-----+------+ +------+------+                         |
|            |               |               |                                |
|            +---------------+---------------+                                |
|                            v                                                |
|                   Results returned to                                       |
|                      Main Agent                                             |
|                                                                             |
+-----------------------------------------------------------------------------+

Why Use Sub-Agents?

  • Isolated Context Windows: Each sub-agent has its own context. They don't pollute the main conversation with irrelevant details.
  • Specialized System Prompts: A code reviewer can be told to focus on security. A test writer can follow your testing conventions.
  • Limited Tool Access: A reviewer only needs read access. A test writer needs write access. You control this per agent.
  • Parallel Execution: Multiple sub-agents can work simultaneously on different parts of a task.

Built-in Sub-Agents

Claude Code comes with two built-in sub-agents:

text
+---------+-----------------------------------------+--------------------------------+
| Agent   | Purpose                                 | Tools                          |
+---------+-----------------------------------------+--------------------------------+
| Explore | Fast codebase search and analysis       | Read-only: ls, cat, grep, find |
| Plan    | Creates detailed implementation plans   | Read-only: analyzes before     |
|         |                                         | suggesting changes             |
+---------+-----------------------------------------+--------------------------------+

Creating Custom Sub-Agents

You can create your own specialized agents.

Step 1: Run the command

bash
/agents

Step 2: Choose to create a new agent

Claude will ask you to describe what this agent should do. Be specific:

text
> Create an agent called "security-reviewer" that:
  - Reviews code for security vulnerabilities
  - Focuses on input validation, SQL injection, XSS, and auth issues
  - Only has read access to files
  - Returns findings in a structured format

Step 3: Claude generates the agent file

The agent file is saved to .claude/agents/security-reviewer.md:

yaml
---
name: security-reviewer
description: Reviews code for security vulnerabilities including
  input validation, SQL injection, XSS, and authentication issues.
  Use when reviewing PRs or auditing code for security.
tools:
  - Read
  - Grep
  - Glob
---

# Security Reviewer

You are a security-focused code reviewer. Your job is to identify
vulnerabilities in code.

## Focus Areas
- Input validation and sanitization
- SQL injection vulnerabilities
- Cross-site scripting (XSS)
- Authentication and authorization flaws
- Sensitive data exposure
- Insecure dependencies

## Output Format
For each issue found:
1. File and line number
2. Vulnerability type
3. Risk level (Critical/High/Medium/Low)
4. Recommended fix

## Guidelines
- Be thorough but avoid false positives
- Prioritize critical issues first
- Suggest specific fixes, not vague advice

Using Sub-Agents

Once created, Claude automatically delegates to sub-agents when appropriate. You can also invoke them explicitly:

text
> Use the security-reviewer agent to audit the authentication module

Or simply:

text
> Use sub-agents to review this codebase

Claude will spin up relevant agents in parallel.

Agent File Locations

text
+--------------------+----------------------------------------------+
| Location           | Scope                                        |
+--------------------+----------------------------------------------+
| ~/.claude/agents/  | Available in all your projects               |
| .claude/agents/    | Available only in this project (can be       |
|                    | version controlled)                          |
+--------------------+----------------------------------------------+

Part 3: Hooks, Automation Triggers

What Are Hooks?

Hooks are shell commands that execute automatically at specific points in Claude Code's lifecycle. They let you inject custom logic without relying on Claude to remember to do something.

text
+-----------------------------------------------------------------------------+
|                            HOOK LIFECYCLE                                   |
+-----------------------------------------------------------------------------+
|                                                                             |
|   +---------------+                                                         |
|   | SessionStart  | --> Runs when Claude Code starts                        |
|   +---------------+                                                         |
|           |                                                                 |
|           v                                                                 |
|   +-------------------+                                                     |
|   | UserPromptSubmit  | --> Runs when you submit a prompt                   |
|   +-------------------+                                                     |
|           |                                                                 |
|           v                                                                 |
|   +---------------+                                                         |
|   |  PreToolUse   | --> Runs BEFORE a tool executes (can block)             |
|   +---------------+                                                         |
|           |                                                                 |
|           v                                                                 |
|   +---------------+                                                         |
|   |   Tool Runs   |                                                         |
|   +---------------+                                                         |
|           |                                                                 |
|           v                                                                 |
|   +---------------+                                                         |
|   | PostToolUse   | --> Runs AFTER a tool completes                         |
|   +---------------+                                                         |
|           |                                                                 |
|           v                                                                 |
|   +---------------+                                                         |
|   |  Notification | --> Runs when Claude sends a notification               |
|   +---------------+                                                         |
|           |                                                                 |
|           v                                                                 |
|   +---------------+                                                         |
|   |     Stop      | --> Runs when Claude finishes responding                |
|   +---------------+                                                         |
|                                                                             |
+-----------------------------------------------------------------------------+

The 8 Hook Events

text
+------------------+---------------------------+------------------------------+
| Hook             | When It Fires             | Use Cases                    |
+------------------+---------------------------+------------------------------+
| SessionStart     | Claude Code starts or     | Load context, check          |
|                  | resumes                   | environment                  |
| UserPromptSubmit | You submit a prompt       | Validate input, add context  |
| PreToolUse       | Before any tool runs      | Block dangerous commands,    |
|                  |                           | validate paths               |
| PostToolUse      | After any tool completes  | Run formatters, log actions  |
| PreCompact       | Before context compaction | Backup transcripts           |
| Notification     | Claude sends notification | Custom alerts, Slack msgs    |
| Stop             | Claude finishes responding| Play sound, send notification|
| SubagentStop     | A sub-agent finishes      | Validate sub-agent output    |
+------------------+---------------------------+------------------------------+

Creating Hooks

Method 1: Interactive Command

bash
/hooks

This opens a menu to configure hooks.

Method 2: Manual Configuration

Create or edit .claude/settings.json:

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {
            "type": "command",
            "command": "prettier --write \"$CLAUDE_FILE_PATH\"",
            "timeout": 30
          }
        ]
      }
    ]
  }
}

Practical Hook Examples

Auto-format after file changes:

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {
            "type": "command",
            "command": "npx prettier --write \"$CLAUDE_PROJECT_DIR\"/**/*.{js,ts,jsx,tsx}"
          }
        ]
      }
    ]
  }
}

Block dangerous commands:

json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo \"$CLAUDE_TOOL_INPUT\" | grep -qE 'rm\\s+-rf|sudo\\s+rm' && exit 2 || exit 0"
          }
        ]
      }
    ]
  }
}

Play sound when Claude finishes:

json
{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "afplay /System/Library/Sounds/Glass.aiff"
          }
        ]
      }
    ]
  }
}

Inject context on session start:

json
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "echo \"Git status: $(git status --short)\nRecent commits: $(git log --oneline -5)\""
          }
        ]
      }
    ]
  }
}

Hook Exit Codes

text
+-----------+------------------------------------------------+
| Exit Code | Behavior                                       |
+-----------+------------------------------------------------+
| 0         | Success - continue normally                    |
| 1         | Failure - show error but continue              |
| 2         | Block - prevent the action (for PreToolUse)    |
+-----------+------------------------------------------------+

Environment Variables Available in Hooks

text
+---------------------+------------------------------------------+
| Variable            | Description                              |
+---------------------+------------------------------------------+
| CLAUDE_PROJECT_DIR  | Absolute path to project root           |
| CLAUDE_TOOL_INPUT   | JSON input for the tool                  |
| CLAUDE_FILE_PATH    | Path to file being modified              |
| CLAUDE_CODE_REMOTE  | "true" if running remotely               |
+---------------------+------------------------------------------+

Part 4: Skills, Packaged Expertise

What Are Skills?

Skills are folders containing instructions, scripts, and resources that Claude loads on-demand. They package expertise into reusable modules.

text
~/.claude/skills/
|
|-- pdf/
|   |-- SKILL.md            <-- Required: metadata + instructions
|   |-- extract_text.py     <-- Optional: executable scripts
|   |-- forms.md            <-- Optional: reference documentation
|   +-- templates/
|       +-- summary.html    <-- Optional: templates
|
+-- code-review/
    |-- SKILL.md
    |-- checklist.md
    +-- patterns/
        |-- security.md
        +-- performance.md

How Skills Work: Progressive Disclosure

Skills use progressive disclosure. Claude loads information only when needed:

text
+-----------------------------------------------------------------------------+
|                      PROGRESSIVE DISCLOSURE                                 |
+-----------------------------------------------------------------------------+
|                                                                             |
|   STAGE 1: Startup                                                          |
|   +---------------------------------------------------------------------+   |
|   | Context Window                                                      |   |
|   |                                                                     |   |
|   |  System Prompt + Skill Metadata Only                                |   |
|   |                                                                     |   |
|   |  "pdf: Manipulates PDF files. Use when working with PDFs."          |   |
|   |  "code-review: Reviews code quality. Use when reviewing code."      |   |
|   |                                                                     |   |
|   |  (~100 tokens per skill)                                            |   |
|   +---------------------------------------------------------------------+   |
|                                                                             |
|   STAGE 2: Skill Triggered                                                  |
|   +---------------------------------------------------------------------+   |
|   | Context Window                                                      |   |
|   |                                                                     |   |
|   |  System Prompt + SKILL.md Contents Loaded                           |   |
|   |                                                                     |   |
|   |  Full instructions from pdf/SKILL.md now in context                 |   |
|   |                                                                     |   |
|   |  (~2-5k tokens)                                                     |   |
|   +---------------------------------------------------------------------+   |
|                                                                             |
|   STAGE 3: Reference Files (As Needed)                                      |
|   +---------------------------------------------------------------------+   |
|   | Context Window                                                      |   |
|   |                                                                     |   |
|   |  SKILL.md references forms.md -> Claude reads it                    |   |
|   |  SKILL.md says "run extract_text.py" -> Claude runs it              |   |
|   |  (Script output added, not script code)                             |   |
|   |                                                                     |   |
|   +---------------------------------------------------------------------+   |
|                                                                             |
+-----------------------------------------------------------------------------+

Creating a Skill

Step 1: Create the directory

bash
mkdir -p ~/.claude/skills/api-design

Step 2: Create SKILL.md

yaml
---
name: api-design
description: Designs RESTful APIs following best practices. Use when
  creating new APIs, reviewing API designs, or discussing REST conventions.
---

# API Design Skill

## Instructions

When designing APIs:

1. Use plural nouns for resources (`/users`, not `/user`)
2. Use HTTP methods correctly:
   - GET: Read (no side effects)
   - POST: Create
   - PUT: Replace
   - PATCH: Partial update
   - DELETE: Remove

3. Return appropriate status codes:
   - 200: Success
   - 201: Created
   - 204: No content
   - 400: Bad request
   - 401: Unauthorized
   - 404: Not found
   - 500: Server error

4. Use consistent response formats:

```json
{
  "data": { ... },
  "meta": { "total": 100, "page": 1 },
  "errors": []
}
```

## Reference
See `conventions.md` for company-specific patterns.

Step 3: Add reference files (optional)

Create conventions.md with your specific API conventions.

Skill Locations

text
+--------------------+--------------------+----------------------+
| Location           | Scope              | Version Controlled?  |
+--------------------+--------------------+----------------------+
| ~/.claude/skills/  | All your projects  | No                   |
| .claude/skills/    | This project only  | Yes (recommended)    |
| Plugin skills      | Via plugin install | Depends on plugin    |
+--------------------+--------------------+----------------------+

Built-in Skills

Claude Code includes skills for document creation:

text
+-------+----------------------------------------------+
| Skill | Purpose                                      |
+-------+----------------------------------------------+
| docx  | Create and edit Word documents               |
| xlsx  | Create and edit Excel spreadsheets           |
| pptx  | Create and edit PowerPoint presentations     |
| pdf   | Create, fill, and manipulate PDFs            |
+-------+----------------------------------------------+

Part 5: MCP Servers, External Connections

What Is MCP?

The Model Context Protocol (MCP) is an open standard for connecting AI to external tools and data. MCP servers give Claude access to things outside your local machine.

text
+-----------------------------------------------------------------------------+
|                           MCP ARCHITECTURE                                  |
+-----------------------------------------------------------------------------+
|                                                                             |
|                         +-----------------+                                 |
|                         |   Claude Code   |                                 |
|                         |   (MCP Client)  |                                 |
|                         +--------+--------+                                 |
|                                  |                                          |
|              +-------------------+-------------------+                      |
|              |                   |                   |                      |
|              v                   v                   v                      |
|     +-----------------+ +-----------------+ +-----------------+             |
|     |  GitHub MCP     | |   Slack MCP     | |  Database MCP   |             |
|     |    Server       | |    Server       | |    Server       |             |
|     +--------+--------+ +--------+--------+ +--------+--------+             |
|              |                   |                   |                      |
|              v                   v                   v                      |
|     +-----------------+ +-----------------+ +-----------------+             |
|     |    GitHub       | |     Slack       | |   PostgreSQL    |             |
|     |      API        | |      API        | |    Database     |             |
|     +-----------------+ +-----------------+ +-----------------+             |
|                                                                             |
+-----------------------------------------------------------------------------+

What Can MCP Do?

With MCP servers connected, Claude can:

  • GitHub: Create PRs, manage issues, review code
  • Slack: Send messages, read channels
  • Databases: Query PostgreSQL, MySQL, etc.
  • Notion: Read and write pages
  • Sentry: Check error logs
  • Figma: Extract designs
  • File systems: Access remote files

Adding MCP Servers

Method 1: CLI Command

bash
# Add GitHub MCP server
claude mcp add github -- npx -y @anthropic-ai/github-mcp-server

# Add with environment variable
claude mcp add github -- npx -y @anthropic-ai/github-mcp-server \
  --env GITHUB_TOKEN=your_token_here

# Add HTTP server
claude mcp add --transport http notion https://mcp.notion.com/mcp

Method 2: Project Configuration

Create .mcp.json in your project root:

json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/github-mcp-server"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    },
    "postgres": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/postgres-mcp-server"],
      "env": {
        "DATABASE_URL": "${DATABASE_URL}"
      }
    }
  }
}

Method 3: User-level Configuration

Add to ~/.claude/settings.json for servers available in all projects.

Popular MCP Servers

text
+-------------------------+----------------------------------+
| Server                  | What It Does                     |
+-------------------------+----------------------------------+
| github-mcp-server       | GitHub repos, issues, PRs        |
| slack-mcp-server        | Slack messages and channels      |
| postgres-mcp-server     | PostgreSQL queries               |
| notion-mcp-server       | Notion pages and databases       |
| puppeteer-mcp-server    | Browser automation               |
| filesystem-mcp-server   | Remote file access               |
| sentry-mcp-server       | Error monitoring                 |
+-------------------------+----------------------------------+

MCP Resources

MCP servers can expose resources that you reference with @:

text
> @github:issues list open issues assigned to me
> @notion:pages find the Q4 roadmap
> @postgres:schema show me the users table structure

Part 6: CLAUDE.md, Memory Files

What Is CLAUDE.md?

CLAUDE.md files are memory files that Claude loads at startup. They contain project context, conventions, and instructions that persist across sessions.

text
+-----------------------------------------------------------------------------+
|                         CLAUDE.MD HIERARCHY                                 |
+-----------------------------------------------------------------------------+
|                                                                             |
|   PRECEDENCE (Higher overrides lower)                                       |
|                                                                             |
|   +-----------------------------------------+                               |
|   |  Enterprise Settings                    |  <-- Managed by admins        |
|   |  (highest precedence)                   |                               |
|   +-----------------------------------------+                               |
|                     |                                                       |
|                     v                                                       |
|   +-----------------------------------------+                               |
|   |  Project: ./CLAUDE.md                   |  <-- Shared with team         |
|   |  (version controlled)                   |      via git                  |
|   +-----------------------------------------+                               |
|                     |                                                       |
|                     v                                                       |
|   +-----------------------------------------+                               |
|   |  Project Local: ./CLAUDE.local.md       |  <-- Your personal            |
|   |  (gitignored)                           |      project overrides        |
|   +-----------------------------------------+                               |
|                     |                                                       |
|                     v                                                       |
|   +-----------------------------------------+                               |
|   |  User: ~/.claude/CLAUDE.md              |  <-- Your personal            |
|   |  (lowest precedence)                    |      preferences              |
|   +-----------------------------------------+                               |
|                                                                             |
+-----------------------------------------------------------------------------+

User-Level CLAUDE.md

Located at ~/.claude/CLAUDE.md, this applies to all your projects.

yaml
# Global Development Preferences

## Code Style
- Use TypeScript strict mode
- Prefer functional programming patterns
- Write descriptive variable names
- Add JSDoc comments for public functions

## Communication
- Be concise and direct
- Show code, don't just describe it
- Ask clarifying questions before large changes

## Testing
- Write tests for new features
- Prefer integration tests over unit tests
- Use descriptive test names

## Git
- Write clear commit messages
- Keep commits atomic
- Reference issue numbers when applicable

Project-Level CLAUDE.md

Located at ./CLAUDE.md in your project root, this is specific to one project and should be version controlled.

yaml
# Project: E-commerce Platform

## Tech Stack
- Next.js 14 with App Router
- TypeScript strict mode
- Tailwind CSS
- PostgreSQL with Prisma ORM
- Redis for caching

## Directory Structure

src/
|-- app/          # Next.js pages and layouts
|-- components/   # React components
|-- lib/          # Utilities and helpers
|-- services/     # Business logic
+-- types/        # TypeScript types

## Key Commands
- `npm run dev` - Start development server
- `npm run build` - Build for production
- `npm run test` - Run test suite
- `npm run lint` - Run ESLint
- `npm run db:migrate` - Run database migrations

## Conventions
- Components use PascalCase
- Utilities use camelCase
- Database tables use snake_case
- API routes return JSON with `{ data, error }` shape

## Important Notes
- Auth is handled by NextAuth.js in `src/lib/auth.ts`
- Environment variables are in `.env.local` (never commit)
- Legacy code in `/legacy` should not be modified

Project Local CLAUDE.md

Located at ./CLAUDE.local.md, this is for personal overrides that shouldn't be shared.

yaml
# My Local Overrides

## Personal Preferences
- I prefer verbose explanations when learning new patterns
- Always show me the git diff before committing

## Local Environment
- My database is running on port 5433 (not default 5432)
- Use `docker compose -f docker-compose.local.yml up`

Editing Memory Files

Use the /memory command to edit memory files directly:

bash
/memory

Or use the # key shortcut to quickly add something:

text
# Always run tests before committing

This appends to the appropriate CLAUDE.md file.

Best Practices for CLAUDE.md

  • Keep it concise: Claude has limited attention. Less is more.
  • Be specific: "Use Tailwind" is better than "use modern CSS practices."
  • Update regularly: Add learnings as you work. Remove outdated info.
  • Use progressive disclosure: Point to other docs instead of including everything.

Part 7: Plugins, Bundled Extensions

What Are Plugins?

Plugins bundle multiple customizations together: slash commands, sub-agents, MCP servers, hooks, and skills. They're shareable packages that install with one command.

text
my-plugin/
|
|-- manifest.json          <-- Plugin metadata
|
|-- commands/              <-- Slash commands
|   |-- review.md
|   +-- deploy.md
|
|-- agents/                <-- Sub-agents
|   |-- security-expert.md
|   +-- performance-analyst.md
|
|-- skills/                <-- Skills
|   +-- api-testing/
|       +-- SKILL.md
|
|-- hooks/                 <-- Hooks
|   +-- hooks.json
|
+-- mcp/                   <-- MCP server configs
    +-- servers.json

Installing Plugins

From a marketplace:

bash
/plugin marketplace add anthropics/skills
/plugin install document-skills@anthropics/skills

From a URL:

bash
/plugin install https://github.com/user/my-plugin

From local directory:

bash
/plugin add /path/to/my-plugin

Managing Plugins

bash
/plugin list                  # See installed plugins
/plugin remove plugin-name    # Uninstall a plugin
/plugin update plugin-name    # Update to latest version

Popular Plugin Marketplaces

text
+-------------------------------+----------------------------------+
| Marketplace                   | Focus                            |
+-------------------------------+----------------------------------+
| anthropics/skills             | Official Anthropic skills        |
| Community marketplaces        | Third-party collections          |
| Your organization's           | Internal tools                   |
| marketplace                   |                                  |
+-------------------------------+----------------------------------+

Part 8: Slash Commands, Custom Shortcuts

What Are Slash Commands?

Slash commands are reusable prompts stored as markdown files. Type / to see available commands.

Creating Slash Commands

User-level (all projects):

bash
mkdir -p ~/.claude/commands

Create ~/.claude/commands/review.md:

yaml
Review this code for:

1. **Security Issues**
   - Input validation
   - SQL injection
   - XSS vulnerabilities

2. **Performance**
   - Unnecessary loops
   - N+1 queries
   - Missing indexes

3. **Code Quality**
   - Naming conventions
   - Code duplication
   - Error handling

Be specific about file locations and line numbers.

Project-level:

Create .claude/commands/fix-issue.md:

yaml
Fix GitHub issue: $ARGUMENTS

Steps:
1. Use `gh issue view $ARGUMENTS` to get details
2. Search codebase for relevant files
3. Implement the fix
4. Write tests
5. Create a commit with message referencing the issue

Using Slash Commands

bash
/review                      # Run user-level command
/project:fix-issue 1234      # Run project command with argument

The $ARGUMENTS Variable

Commands can accept arguments using $ARGUMENTS:

yaml
Create a new component called $ARGUMENTS with:
- TypeScript
- Tailwind styling
- Unit tests
- Storybook story

Usage: /project:new-component Button

Part 9: Putting It All Together

A Complete Setup Example

Here's how everything fits together for a real project:

text
my-project/
|
|-- .claude/
|   |-- settings.json              # Hooks and permissions
|   |-- settings.local.json        # Personal settings (gitignored)
|   |
|   |-- commands/                  # Project slash commands
|   |   |-- review-pr.md
|   |   |-- fix-issue.md
|   |   +-- deploy.md
|   |
|   |-- agents/                    # Project sub-agents
|   |   |-- security-reviewer.md
|   |   |-- test-writer.md
|   |   +-- docs-writer.md
|   |
|   +-- skills/                    # Project skills
|       +-- api-conventions/
|           +-- SKILL.md
|
|-- .mcp.json                      # MCP server configuration
|
|-- CLAUDE.md                      # Project memory (version controlled)
|-- CLAUDE.local.md                # Personal memory (gitignored)
|
+-- src/
    +-- ...

Workflow Example

text
+-----------------------------------------------------------------------------+
|                      EXAMPLE WORKFLOW: FIX A BUG                            |
+-----------------------------------------------------------------------------+
|                                                                             |
|   You: /project:fix-issue 1234                                              |
|                                                                             |
|   +---------------------------------------------------------------------+   |
|   |                                                                     |   |
|   |   1. SessionStart hook runs                                         |   |
|   |      +-> Loads git status and recent commits                        |   |
|   |                                                                     |   |
|   |   2. Claude reads CLAUDE.md                                         |   |
|   |      +-> Understands project conventions                            |   |
|   |                                                                     |   |
|   |   3. Claude uses GitHub MCP server                                  |   |
|   |      +-> Fetches issue #1234 details                                |   |
|   |                                                                     |   |
|   |   4. Claude delegates to Explore sub-agent                          |   |
|   |      +-> Finds relevant files without bloating context              |   |
|   |                                                                     |   |
|   |   5. Claude makes the fix                                           |   |
|   |      +-> PreToolUse hook validates file paths                       |   |
|   |      +-> PostToolUse hook runs Prettier                             |   |
|   |                                                                     |   |
|   |   6. Claude delegates to test-writer sub-agent                      |   |
|   |      +-> Adds test coverage                                         |   |
|   |                                                                     |   |
|   |   7. Claude commits with issue reference                            |   |
|   |      +-> Uses GitHub MCP to create PR                               |   |
|   |                                                                     |   |
|   |   8. Stop hook runs                                                 |   |
|   |      +-> Desktop notification sent                                  |   |
|   |                                                                     |   |
|   +---------------------------------------------------------------------+   |
|                                                                             |
+-----------------------------------------------------------------------------+

Quick Reference

File Locations

text
+----------+---------------------------+---------------------------+
| What     | User-Level                | Project-Level             |
+----------+---------------------------+---------------------------+
| Memory   | ~/.claude/CLAUDE.md       | ./CLAUDE.md               |
| Settings | ~/.claude/settings.json   | ./.claude/settings.json   |
| Commands | ~/.claude/commands/       | ./.claude/commands/       |
| Agents   | ~/.claude/agents/         | ./.claude/agents/         |
| Skills   | ~/.claude/skills/         | ./.claude/skills/         |
| MCP      | ~/.claude/settings.json   | ./.mcp.json               |
+----------+---------------------------+---------------------------+

Useful Commands

text
+----------+------------------------------------+
| Command  | Purpose                            |
+----------+------------------------------------+
| /agents  | Manage sub-agents                  |
| /hooks   | Configure hooks                    |
| /memory  | Edit memory files                  |
| /plugin  | Manage plugins                     |
| /config  | Open settings                      |
| /model   | Switch AI model                    |
| /compact | Compress context                   |
+----------+------------------------------------+

Hook Types

text
+------------------+---------+----------------------------+
| Hook             | Blocks? | When to Use                |
+------------------+---------+----------------------------+
| SessionStart     | No      | Load context               |
| UserPromptSubmit | Yes     | Validate input             |
| PreToolUse       | Yes     | Block dangerous commands   |
| PostToolUse      | No      | Run formatters             |
| Stop             | No      | Notifications              |
+------------------+---------+----------------------------+