Головна / Статті / Шпаргалка з Claude Code: CLAUDE.md, хуки, скіли, MCP і режими

Шпаргалка з Claude Code: CLAUDE.md, хуки, скіли, MCP і режими

Короткий довідник з Claude Code: CLAUDE.md, промпти, правила, хуки, скіли, MCP, субагенти, worktree, режими дозволів, основні команди й промпти, які варто зберегти.

1905 слів

Claude Code — агентний помічник Anthropic для програмування. Він уміє не лише писати фрагменти коду. Він може:

  • Розібратися в наявній кодовій базі
  • Читати й редагувати кілька файлів одночасно
  • Запускати команди в терміналі
  • Писати тести й запускати їх
  • Знаходити помилки
  • Рефакторити код
  • Працювати з Git
  • Викликати інструменти MCP і запускати хуки
  • Передавати роботу субагентам
  • Робити фічі за інструкціями, написаними звичайною мовою

Базова модель

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

Три терміни легко сплутати. Claude — це ШІ-модель і асистент Anthropic: розуміє природну мову, міркує, працює з кодом і документами та береться за безліч завдань. Claude Code — агентний інструмент для розробки, який дає Claude змогу працювати з кодовою базою, файлами, командами термінала, тестами, Git і зовнішніми інструментами, щоб доводити завдання до кінця. ШІ-агент — будь-яка система, яка розуміє мету, планує кроки, користується інструментами, діє, перевіряє результат і повторює, доки завдання не виконано. Одну схему варто запам'ятати:

                         🤖 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

Команди

У Claude Code є набір вбудованих слеш-команд, і вивчати їх найпростіше за його власним списком команд.

CLAUDE.md

CLAUDE.md — файл з інструкціями для проєкту. Він дає Claude Code контекст конкретного проєкту, команди, нотатки про архітектуру й правила написання коду, тож вважайте його довідником проєкту для 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

Користь у тому, що вказівки зберігаються між сесіями, і розробникам не доводиться знову й знову пояснювати архітектуру, команди, домовленості й правила.

Промпти

Промпт — інструкція природною мовою, яка пояснює ШІ завдання або мету. Добрий агентний промпт спершу змушує розібратися, а вже потім щось змінювати:

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.

Правила

Правила — це обмеження або вказівки, що визначають, як агент виконує завдання. У великих проєктах інструкції можна розбити за темами всередині .claude/rules/:

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

Файл із правилами може виглядати так:

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.

Хуки

Хук — автоматична дія, яка спрацьовує на певну подію, наприклад запуск команди чи перевірки після конкретної дії агента. Хуки додають у роботу агента автоматизацію, одноманітність і страховку. Щось сталося — дія виконується сама. Наприклад:

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

У реальному проєкті хуки можуть лежати в такій теці:

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

Скіли

Скіли — це багаторазові спеціалізовані сценарії або інструкції, розкладені за темами:

.claude/skills/

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

Кожен скіл — короткий документ, наприклад такий:

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 (Model Context Protocol) — стандартний протокол, через який ШІ-застосунки підключаються до зовнішніх інструментів і джерел даних.

Субагенти

Субагенти — спеціалізовані агенти, яким основний агент може доручити частини великого завдання, щоб складну роботу можна було розділити:

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

Git worktree

Git worktree дає кілька робочих каталогів, прив'язаних до різних гілок, тож кілька завдань можуть просуватися незалежно:

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

Для ШІ-агентів це зручно: два агенти можуть займатися різними завданнями й не штовхатися постійно в одному робочому каталозі. Worktree — ізольований робочий простір для роботи з Git.

Режими дозволів

У Claude Code є режими дозволів, які визначають, наскільки вільно Claude користується інструментами:

┌──────────────────────────────────────────────────────────┐
│                 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.                                 │
└──────────────┴───────────────────────────────────────────┘

Який режим обрати, залежить від того, скільки нагляду потребує завдання.

README.md і CLAUDE.md

README.md описує проєкт для людей, а CLAUDE.md містить інструкції й контекст саме для Claude Code.

/clear і /compact

/clear повністю очищає контекст поточної розмови. /compact робить із нього стисле резюме, щоб робота тривала з меншим контекстом.

@file

@file посилається на конкретний файл і передає його вміст Claude як контекст для завдання.

Шорткат #

Префікс # — швидкий спосіб додати інструкції чи пам'ять, що стосуються проєкту.

Навіщо тести в агентній розробці

Агент вносить у кодову базу справжні зміни. Тести показують йому, чи ці зміни працюють, і допомагають знаходити й виправляти збої.

Підсумкова шпаргалка

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

Універсальні промпти, які варто зберегти

Загальний стартовий промпт для незнайомого застосунку:

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.

Щоб розібратися в архітектурі:

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.

Щоб знайти головні точки входу:

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.

Щоб Claude усе протестував:

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 через MCP

Для автоматизації браузера попросіть Claude використати налаштований MCP-сервер Playwright.

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.

Десять промптів варто вивчити напам'ять:

① 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."