← ALL POSTS
Claude CodeAI ToolsDeveloper ProductivityAgentic AI

Claude Code in Practice: CLAUDE.md, Skills, Sub-agents and How They Fit Together

·Srinivasa Varma·8 min read

There's a version of AI-assisted coding that goes like this: you open a chat, type a question, copy the answer, paste it into your editor, fix what broke, and repeat. It works, kind of — the same way a calculator works if you also do the arithmetic in your head first.

Then there's another version, one that most developers haven't fully discovered yet, where the AI knows your project conventions, runs specialized reviewers on your code, and delegates complex tasks to focused sub-agents — all without you writing the same instructions over and over.

This post is about that second version, specifically inside Claude Code. But if you're coming from Cursor, everything here has a direct parallel. Cursor Rules → CLAUDE.md. Cursor's slash commands → Claude Code's skills. Cursor's background agents → Claude Code's sub-agents. Same ideas, different names.


The Problem with "Just Prompting"

Every time you start a fresh conversation with an AI coding assistant, it knows nothing about you. Nothing about the fact that your team writes tests first. Nothing about the Go version you're pinned to. Nothing about why that one weird middleware exists. You either re-explain it every session, or you get answers that technically work but don't fit your project at all.

This is the context tax — the overhead of bringing an AI up to speed before it can actually help you. The tools below are all about eliminating that tax.


CLAUDE.md — Teaching the AI Your Project's Rules

CLAUDE.md is a plain markdown file you drop at the root of your project (or anywhere in the tree). Claude Code reads it at the start of every session. Think of it as a persistent briefing document — the things you'd tell a new team member on day one.

What goes in it?

# Project Rules
 
## Tech Stack
- Python 3.11, FastAPI, PostgreSQL 15
- No ORM — raw SQL with asyncpg
 
## Code Style
- Functions stay under 40 lines
- No print() in production code — use the logger
- Type hints on everything, including return types
 
## Testing
- Write tests before implementation
- Never mock the database — integration tests only
 
## Git
- Commit messages: "<type>: <what changed> — <why>"
- No force-push to main, ever

That's it. Now Claude knows your stack, your opinions, your non-negotiables. When it suggests code, it won't reach for SQLAlchemy in a project that explicitly avoids ORMs. When it writes a commit message, it follows your format.

A real example of what changes:

Without CLAUDE.md, Claude might help you add a new API endpoint and suggest:

# "here's a handy debug print"
print(f"Created user: {user.id}")

With CLAUDE.md containing "No print() in production code — use the logger," it instead writes:

logger.info("Created user", extra={"user_id": user.id})

Small difference, but multiply it across a week of coding and you stop doing cleanup passes.

Nesting matters too. You can have a root-level CLAUDE.md for project-wide rules and sub-directory CLAUDE.md files for team-specific ones. The frontend team's src/frontend/CLAUDE.md can have React component patterns that don't apply to the backend engineers. Claude stacks them all.


Commands — Quick Actions at Your Fingertips

Slash commands (/help, /clear, /review) are the interactive layer. You type them in the Claude Code prompt and they trigger specific behaviors.

The built-in ones are immediately useful:

CommandWhat it does
/helpShows available commands and features
/clearResets the conversation context
/reviewReviews the current branch's changes
/initGenerates a CLAUDE.md for your project

But the real power is that commands can be extended — which is where skills come in.


Skills — Commands You Build Yourself

A skill is a reusable workflow packaged as a slash command. If you find yourself typing the same kind of request repeatedly — "check this migration for safety", "write tests for whatever I just changed", "summarize what's in this PR" — that's a skill waiting to be born.

Skills live in .claude/commands/ in your project. Each one is a markdown file where you describe exactly what you want the AI to do.

Example: a /summarize-pr skill

# .claude/commands/summarize-pr.md
 
Look at the git diff between the current branch and main.
Write a pull request description with:
- A one-sentence summary of what changed and why
- A bullet list of specific changes
- A testing checklist
 
Keep it under 200 words. No fluff.

Now /summarize-pr is a command anyone on the team can run. The instructions are in version control. No one has to remember how to phrase the prompt.

Skills can also be parameterized. Pass arguments after the command name and Claude uses them in context:

/scaffold-feature user-authentication

The skill's markdown can reference $ARGUMENTS and Claude incorporates whatever you typed. It's not magic — it's just prompt engineering made reusable.


Sub-agents — Delegating the Hard Work

This is where things get genuinely interesting, and also where most developers are still catching up.

A sub-agent is a separate Claude instance that you spin up to handle a specific part of a task. The main Claude orchestrates; the sub-agents do focused work and report back.

Why does this matter?

Imagine asking Claude to "refactor the entire authentication module." That's a big task. It involves reading lots of files, making many decisions, writing new code, running tests. If you do it in one long conversation, the context window fills up, the AI loses track of earlier decisions, and the quality drifts.

With sub-agents, you can break it up:

Main Claude
├── Sub-agent A: Read all auth files, map the current structure
├── Sub-agent B: Write the refactored code based on A's map
└── Sub-agent C: Write tests for B's new code

Each agent has a clean, focused context. They don't step on each other. The main Claude synthesizes their outputs.

But how do you actually create sub-agents and assign them tasks?

You do it inside a skill file. The skill describes the orchestration — which sub-agent to spawn, what to tell it, and what to do with the result. Here's a real example: a /migrate-auth skill that handles migrating JWT-based auth to session-based auth.

# .claude/commands/migrate-auth.md
 
You are orchestrating a JWT-to-session auth migration. Work in three steps:
 
**Step 1 — Explore (read-only)**
Spawn an Explore sub-agent with this task:
"Find every file in the codebase that imports jsonwebtoken,
calls verify(), or calls sign(). For each file, note what
it does with the token. Return a full list with file paths
and a one-line summary of each file's role."
 
**Step 2 — Plan (no edits yet)**
Using the file map from Step 1, spawn a Plan sub-agent:
"Given these files and their roles, write a step-by-step
migration plan. Specify which files to change in which order
so the app is never in a broken intermediate state.
Flag any edge cases."
 
**Step 3 — Code (implement)**
Using the plan from Step 2, spawn a Code sub-agent:
"Execute this migration plan exactly. Edit each file in the
specified order. Remove all JWT logic. Do not touch anything
outside the plan."
 
Once all three steps are done, summarise what changed and
flag anything that needs a manual review.

Now you run /migrate-auth in Claude Code. You don't touch a file. The skill orchestrates the Explore → Plan → Code sequence, each agent working with a clean focused context, and reports back when it's done.

The same pattern works for any large task. A /audit-security skill might spawn two Explore agents in parallel — one hunting for raw SQL queries, one finding unvalidated user inputs — then hand both results to a single reasoning agent that looks for vulnerabilities across the combined picture. Parallel here means both searches happen at the same time, cutting the wait in half.


The mental model:

CLAUDE.md          = What Claude knows about your project (always on)
Skills / Commands  = What Claude can do on demand (triggered by you)
Sub-agents         = Who Claude delegates complex work to (autonomous)

How These Four Things Work Together

Here's a real workflow I use when starting work on a feature:

Step 1 — CLAUDE.md is always there. The AI already knows my conventions before I type a word.

Step 2 — I run /plan before touching code. A planning skill that spawns an Explore sub-agent to map the relevant files, then drafts a step-by-step implementation plan. I review it, tweak it, approve it.

Step 3 — Claude implements. Sub-agents handle isolated pieces in parallel — one for the database layer, one for the API layer — each with a focused context.

Step 4 — I run /review. The built-in review command examines the diff and flags anything that violates conventions or looks risky.

Step 5 — I run /summarize-pr. A skill generates the pull request description I'll actually use.

The whole thing takes less time than the manual version, and more importantly, it's consistent. The rules in CLAUDE.md apply every time. The skills run the same way every time. I'm not reinventing the prompt every day.


Common Mistakes (and How to Avoid Them)

Putting too much in CLAUDE.md. Rules that are too broad ("write good code") or too long get diluted. Keep it to things that would actually change the AI's output. If you're not sure a rule matters, leave it out and add it when you hit the case.

Building skills for one-off tasks. Skills pay off when you use them repeatedly or share them with a team. A skill that runs once isn't a skill — it's just a prompt you over-engineered.

Expecting sub-agents to coordinate themselves. Sub-agents are parallel workers, not autonomous collaborators. They don't talk to each other; the main Claude synthesizes their outputs. Design your orchestration accordingly.

Not versioning any of this. Your CLAUDE.md and your .claude/commands/ directory should be in git. They're part of your project's tooling, same as your linter config or your CI pipeline. When they're not versioned, they drift. When they drift, they stop being useful.


Where to Start

Start with CLAUDE.md. Open the project you spend the most time in, create the file, and write down the three things you wish every AI response already knew about it. That's it. You'll feel the difference the next day.

After a week, look at what prompts you typed more than once. If a pattern shows up, turn it into a skill. It takes ten minutes and you'll never type that prompt again.

Sub-agents are the last thing to reach for — when a task is genuinely too large to hold in one context, or when two pieces of work are completely independent and can run at the same time. Don't orchestrate for the sake of it.

The whole system is just structured context. The more deliberately you build it, the less you have to repeat yourself — and the more the AI can actually focus on the hard parts.