Галоўная / Артыкулы / Claude Code Cheat Sheet: CLAUDE.md, Hooks, Skills, MCP and Modes

Артыкул апублікаваны на англійскай мове.

Claude Code Cheat Sheet: CLAUDE.md, Hooks, Skills, MCP and Modes

A quick reference to Claude Code: CLAUDE.md, prompts, rules, hooks, skills, MCP, sub-agents, worktrees, permission modes, key commands and prompts worth saving.

1905 слоў

Claude Code is Anthropic's agentic coding assistant. Writing snippets isn't all it does. It can:

  • Make sense of an existing codebase
  • Read and edit several files at once
  • Run commands in the terminal
  • Write tests and run them
  • Track down errors
  • Refactor code
  • Handle Git operations
  • Call MCP tools and fire hooks
  • Pass work to subagents
  • Build features from instructions written in plain language

The basic mental model

You
 ↓
Natural-language prompt
 ↓
Claude Code
 ↓
Understand codebase
 ↓
Plan
 ↓
Read files
 ↓
Modify code
 ↓
Run tests / commands
 ↓
Review result
 ↓
Iterate

Three terms get mixed up easily. Claude is Anthropic's AI model and assistant, able to follow natural language, reason over information, handle code and documents, and take on many AI tasks. Claude Code is the agentic coding tool that lets Claude work with a software codebase, files, terminal commands, tests, Git and outside tools to finish development tasks. An AI agent is any system that can grasp a goal, plan steps, use tools, act, check the results and iterate until the task is done. One diagram is worth memorizing:

                         🤖 CLAUDE
                            │
                            ↓
                     CLAUDE CODE
                            │
                     ┌──────┴──────┐
                     ↓             ↓
                   PROMPT        RULES
                "Do this"      "Follow this"
                     │             │
                     └──────┬──────┘
                            ↓
                          AGENT
                            │
              ┌─────────────┼─────────────┐
              ↓             ↓             ↓
           Commands       Skills         Tools
              │             │             │
              ↓             ↓             ↓
          /help etc.    Reusable        Terminal
                        capability      Git
                                        Files
                                         │
                              ┌──────────┴──────────┐
                              ↓                     ↓
                             MCP                  HOOKS
                              ↓                     ↓
                       External tools        Automatic actions
                              │
                              ↓
                         SUB-AGENTS
                              ↓
                       Delegated tasks
                              │
                              ↓
                         WORKTREES
                              ↓
                       Isolated Git work

Commands

Claude Code ships with a set of built-in slash commands, which are best learned from its own command list.

CLAUDE.md

CLAUDE.md is a project instruction file. It gives Claude Code project-specific context, commands, architecture notes and coding guidelines, so think of it as the project handbook for Claude.

CLAUDE.md

Project:
Android banking application

Architecture:
Clean Architecture + MVVM

Modules:
app
core
network
database
feature-login

Commands:
./gradlew test
./gradlew lint

Rules:
- Use Kotlin
- Use Coroutines
- Use existing centralized utilities
- Add tests for new functionality
- Don't duplicate networking code

It's useful because it carries persistent guidance, which means developers don't keep re-explaining architecture, commands, conventions and rules.

Prompts

A prompt is the natural-language instruction that tells the AI what the task or goal is. A strong agentic prompt investigates before it changes anything:

First investigate the existing authentication flow.

Do not modify anything yet.

Explain:
- frontend flow
- backend flow
- API involved
- relevant files
- likely problem

Then propose a fix.

After approval, implement it, test it,
review the diff, and commit the changes.

Rules

Rules are constraints or guidelines that govern how the agent carries out a task. Larger projects can split instructions by topic inside .claude/rules/:

.claude/rules/
├── testing.md
├── security.md
├── frontend.md
├── backend.md
└── android.md

A rules file might read:

Rules:

- Use Kotlin.
- Follow MVVM.
- Do not create duplicate utility functions.
- Reuse existing components.
- Write tests for new functionality.
- Do not modify unrelated modules.
- Never expose secrets.
- Run lint before committing.

Hooks

A hook is an automated action triggered by a specific event, for example running a command or a validation after a particular agent action. Hooks bring automation, consistency and guardrails to what the agent does. Whenever something happens, an action runs automatically. For example:

Before build
     ↓
   HOOK
     ↓
Check:
- formatting
- lint
- dependencies
- tests
     ↓
Build

In a real project the hooks could live in a folder like this:

.claude/
└── hooks/
      │
      ├── lint
      ├── test
      ├── dependency-check
      ├── security-check
      └── pre-build

Skills

Skills are reusable, specialized workflows or instructions, stored per topic:

.claude/skills/

├── android-development/
├── compose-ui/
├── kotlin-testing/
├── api-integration/
└── code-review/

Each skill is a short document, such as this one:

Android Development Skill

When modifying Android code:

- Use Kotlin
- Follow MVVM
- Use Coroutines
- Use StateFlow
- Follow existing architecture
- Add tests
- Run lint
- Avoid duplicate utilities

MCP

MCP, the Model Context Protocol, is a standardized protocol that lets AI applications connect to external tools and data sources.

Sub-agents

Sub-agents are specialized agents that the main agent can delegate parts of a bigger task to, so complex work gets divided up:

                 Main Agent
                     │
        ┌────────────┼────────────┐
        ↓            ↓            ↓
    Sub-agent    Sub-agent    Sub-agent
     Backend      Security       Tests
        │            │            │
        └────────────┼────────────┘
                     ↓
                Main Agent
                     ↓
                Final result

Git worktrees

A Git worktree gives you several working directories tied to different branches, so multiple tasks can move forward independently:

                 Git Repository
                       │
          ┌────────────┼────────────┐
          ↓            ↓            ↓
       Worktree A   Worktree B   Worktree C
       Feature A    Feature B    Bug Fix

That helps with AI agents, since two of them can work on separate tasks without constantly colliding in one working directory. A worktree is an isolated workspace for Git work.

Permission modes

Claude Code has permission modes that control how much freedom Claude has when using tools:

┌──────────────────────────────────────────────────────────┐
│                 CLAUDE CODE MODES                       │
├──────────────┬───────────────────────────────────────────┤
│ 🖐 MANUAL    │ Claude asks for approval before actions   │
│              │ or changes. You stay in control.         │
├──────────────┼───────────────────────────────────────────┤
│ ✏️ EDIT      │ Claude can edit the selected text/file    │
│              │ or make the requested code changes.      │
├──────────────┼───────────────────────────────────────────┤
│ 📋 PLAN      │ Claude explores the codebase, analyzes    │
│              │ the problem and presents a plan BEFORE    │
│              │ making edits.                             │
├──────────────┼───────────────────────────────────────────┤
│ ⚡ AUTO      │ Claude can take actions automatically     │
│              │ and automatically check/continue through  │
│              │ the task.                                 │
└──────────────┴───────────────────────────────────────────┘

Which mode to pick depends on how much supervision the task needs.

README.md versus CLAUDE.md

README.md documents the project for people, whereas CLAUDE.md holds instructions and context meant specifically for Claude Code.

/clear versus /compact

/clear wipes the current conversation context. /compact summarizes and compresses it, so the work can carry on with less context.

@file

Typing @file references a specific file and passes its contents to Claude as context for the task.

The # shortcut

The # prefix is a quick way to add project-specific instructions or memory.

Why tests matter with agentic coding

The agent makes real changes to a codebase. Tests tell it whether those changes work and help it spot and fix failures.

Final cheat sheet

Claude
→ Anthropic's AI model/assistant

Claude Code
→ Agentic coding tool

Agent
→ AI that can reason + use tools + take actions

Prompt
→ What I ask it to do

Rules
→ Constraints it must follow

CLAUDE.md
→ Project handbook/instructions

Commands
→ Special controls like /help, /init, /clear, /compact

Hooks
→ Automatic actions triggered by events

Skills
→ Reusable specialized capabilities/instructions

Templates
→ Predefined reusable structure

MCP
→ Connect Claude to external tools/data

Sub-agents
→ Specialized agents delegated work

Worktrees
→ Separate Git workspaces

README.md
→ Human project documentation

CLAUDE.local.md
→ Local/personal project instructions
  where that convention is used

audit_summary.md
→ Usually custom audit report

clone.md
→ Usually custom setup/clone documentation

push_to_github.sh
→ Usually custom Git automation script

push_now.md
→ Usually custom push checklist

Generic prompts worth keeping

A general starting prompt for an unfamiliar application:

I am new to this application.

Do not modify anything.

Give me a high-level overview of the application.

Explain:
- What the application does
- Main features
- Main technologies
- Project structure
- Modules
- Important packages
- Architecture
- Main entry points
- External services
- Database
- APIs
- Testing
- Build and deployment process

Start with a simple explanation for a developer who is new to this project.

To understand the architecture:

Analyze the architecture of this application.

Do not modify anything.

Explain:

- Architecture pattern
- Modules
- Layers
- Dependency flow
- Data flow
- API layer
- Business layer
- Data layer
- UI layer

Identify the main architectural patterns being used.

Then draw an architecture diagram.

To find the main entry points:

Identify the main entry points of this application.

For each entry point, explain:

- File
- Class/function
- What triggers it
- What it calls next
- Where the request eventually ends

Create a simple flow diagram.

To have Claude test everything:

Analyze the changes made in this task.

Identify all relevant tests.

Run:
- Unit tests
- Integration tests
- UI tests where applicable
- Lint
- Type checks
- Build

If anything fails:
- investigate the root cause
- fix it
- rerun the failing checks

At the end, give me a summary of:
PASS / FAIL / NOT RUN

Playwright with MCP

For browser automation, ask Claude to use a configured Playwright MCP server.

Use the Playwright MCP server.

Open the application in the browser.

Visit the login page.

Take a screenshot.

Then:
1. Enter the test credentials.
2. Click Login.
3. Verify that the dashboard appears.
4. Navigate to [PAGE].
5. Click [LINK/BUTTON].
6. Take screenshots at the important steps.
7. Report any errors or unexpected behavior.

Do not modify the application.

Ten prompts are worth committing to memory:

① OVERVIEW
"Give me an overview of this application."

② STRUCTURE
"Explain the project structure and important files."

③ FLOW
"Trace a user's query from frontend to backend and draw a diagram."

④ DOCUMENT
"Trace how a document is processed from upload to final answer."

⑤ RUN
"How do I run, test, lint and build this application?"

⑥ PLAN
"Analyze the existing implementation and create a plan before editing."

⑦ IMPLEMENT
"Implement this feature, reuse existing code, test it and review the diff."

⑧ DEBUG
"Reproduce this error, find the root cause, fix it and add a regression test."

⑨ UI
"Use Playwright MCP to test the user flow and take screenshots."

⑩ GIT
"Review the diff, run checks, resolve conflicts if needed, and commit."