12 Claude Code Features: Detailed Explanation with Examples
1. Overview
Claude Code is a coding agent that runs in your terminal, able to read, edit, run commands, and self-check code in your projects. The catch is: the agent is powerful, but if used with default settings, it easily “goes astray” – editing the wrong files, exhausting the context window, or running dangerous commands. This article explains 12 features that help you control this agent deliberately. After reading, you’ll know how to configure CLAUDE.md, permissions, hooks, MCP… so Claude Code works according to your team’s conventions, on an example Spring Boot project with Order, Customer, PaymentService.
2. CLAUDE.md
CLAUDE.md is a memory file that Claude Code automatically reads at the start of each session. It’s where you declare code conventions, directory structure, build commands, style guides – so the agent doesn’t have to ask again each time.
# CLAUDE.md
## Architecture
- Package `com.nonladev.order`: domain Order, Customer
- Package `com.nonladev.payment`: PaymentService, PaymentGateway (interface)
## Conventions
- Always write JUnit 5 + AssertJ tests for new public methods
- Don't use `@Autowired` field injection, only constructor injection
- Run `mvn verify` before reporting "done"
## Common Commands
- Build: `mvn -q clean verify`
- Run local: `mvn spring-boot:run`
Claude reads this file before performing any task in the session. If you ask to “add a refund method to PaymentService”, the agent automatically knows to use constructor injection and write tests alongside – no need to remind it.
Note: Don’t cram too many details into CLAUDE.md. A long file consumes context window right from the start of the session, while most of the content may not relate to the current task.
3. Permissions
Permissions control which tools Claude can use and which are blocked – important because the agent has the right to run real shell commands.
{
"permissions": {
"allow": [
"Bash(mvn *)",
"Edit(src/main/java/**)"
],
"deny": [
"Bash(rm -rf *)",
"Edit(src/main/resources/application-prod.properties)"
]
}
}
This settings.json file is placed in the .claude/ directory. The allow line lets the agent run mvn and edit files in src/main/java, but the deny line absolutely blocks recursive deletion commands and blocks editing production config files. When Claude wants to exceed permissions, it will ask you for confirmation before executing.
Common mistake: setting permissions too broad (
allow: ["*"]) lets the agent run any command without asking – dangerous for sensitive config files or secrets.
4. Plan Mode
Plan Mode forces Claude to present a plan before touching the code. You review the plan, edit it if needed, then let it run.
> Add partial refund functionality to PaymentService
[PLAN MODE]
1. Add method refundPartial(Order order, BigDecimal amount) to PaymentService
2. Validate amount <= order.getTotalPaid()
3. Call PaymentGateway.refund(...)
4. Write PaymentServiceTest for 2 cases: valid, amount exceeds total
Would you like me to execute this plan? [y/n/edit]
When you answer edit, Claude will revise the plan according to your suggestions (for example, adding an audit logging step) before touching the actual source code. This approach is especially useful for tasks that modify many files, because you detect wrong directions right at the plan stage, not after the code has been messed up.
5. Checkpoints
Checkpoints are automatic snapshots of the project at important moments in the session, letting you “rewind” if the agent messes up.
# View checkpoint history in current session
/rewind
# Output
Checkpoint 1 - 10:02 - before editing PaymentService
Checkpoint 2 - 10:05 - after adding refundPartial
Checkpoint 3 - 10:09 - after modifying test (currently broken)
# Revert to checkpoint 2
/rewind 2
Unlike git commits, checkpoints don’t require you to create them manually – Claude Code automatically saves before each major change. If the agent modifies the test in the wrong direction (for example, commenting out assertions to make the test “pass”), you can rewind to the previous state without needing a manual git reset.
Note: checkpoints only live within the current session scope, they don’t replace git. You should still make real commits when reaching a milestone.
6. Skills
Skills are reusable instruction files that Claude automatically applies when it detects a matching task – you don’t need to call them by name each time.
---
name: spring-boot-test-writer
description: Use when writing tests for service layer in Spring Boot projects
---
When writing tests for a Service class:
1. Use JUnit 5 + AssertJ, don't use Hamcrest
2. Mock dependencies with Mockito, name variables `mock<Dependency>`
3. Name test methods following `should_<expected>_when_<condition>` pattern
This file is placed in .claude/skills/spring-boot-test-writer.md. When you ask to “write tests for PaymentService”, Claude automatically recognizes the matching skill and applies the conventions within it, resulting in:
class PaymentServiceTest {
private final PaymentGateway mockGateway = mock(PaymentGateway.class);
private final PaymentService paymentService = new PaymentService(mockGateway);
@Test
void should_refundAmount_when_amountIsWithinPaidTotal() {
Order order = new Order("ORD-1", BigDecimal.valueOf(200));
paymentService.refundPartial(order, BigDecimal.valueOf(50));
verify(mockGateway).refund(order.getId(), BigDecimal.valueOf(50));
}
@Test
void should_throwException_when_amountExceedsPaidTotal() {
Order order = new Order("ORD-2", BigDecimal.valueOf(100));
assertThatThrownBy(() -> paymentService.refundPartial(order, BigDecimal.valueOf(150)))
.isInstanceOf(IllegalArgumentException.class);
}
}
Skills differ from CLAUDE.md in that: CLAUDE.md is always loaded, while skills load only when the context needs them – saving context window for projects with many specialized conventions.
7. Hooks
Hooks run your shell scripts at points in the agent’s lifecycle, for example PreToolUse (before calling a tool) or PostToolUse (after calling a tool).
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit",
"command": "mvn -q -pl . checkstyle:check"
}
]
}
}
Each time Claude finishes editing a file (Edit tool), the hook automatically runs checkstyle:check. If the command fails, the output returns to Claude, and the agent automatically fixes the code according to the style error before reporting the task complete — you don’t need to run the check manually.
[PostToolUse] mvn checkstyle:check
ERROR: PaymentService.java:42: Line is longer than 120 characters
→ Claude automatically shortens line 42 and runs the check again
When not to use: hooks run each time a tool is called, so if the script is heavy (full project build), the session will slow down noticeably. Only hook into lifecycle events that need quick checks.
8. MCP
MCP (Model Context Protocol) connects Claude with external systems – databases, internal APIs, issue trackers – as a standardized tool.
{
"mcpServers": {
"postgres-orders": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres",
"postgresql://localhost:5432/orders_db"]
}
}
}
After registering this server in .claude/settings.json, you can ask directly:
> How many Orders with status PENDING are there in the orders table?
[MCP: postgres-orders] SELECT COUNT(*) FROM orders WHERE status = 'PENDING';
→ 37 orders are PENDING
Claude automatically generates the SQL statement, calls it via the MCP server, and returns actual results from the database — no need for you to manually copy the query to another terminal.
9. Plugins
A Plugin is a bundle that packages related skills, MCP server, and hooks together, letting you install once instead of configuring each part separately.
/plugin install spring-boot-toolkit
This command installs a hypothetical plugin containing: a skill for writing Spring Boot tests, a hook that runs mvn verify after each edit, and an MCP server that connects to Spring Boot Actuator endpoints so the agent can self-check health. Instead of you having to write 3 separate config files (skill, hook, mcp) like sections 6–8, the plugin bundles them into a single package that can be shared with the entire team via one command line.
10. Context
Context is the current session’s context window — all files read, conversation history, command output. The /context command shows you how much it’s currently using.
/context
Context usage: 48,200 / 200,000 tokens (24%)
- CLAUDE.md: 1,200 tokens
- Files read: PaymentService.java, Order.java, PaymentServiceTest.java (6,400 tokens)
- Conversation history: 38,000 tokens
- Tool outputs: 2,600 tokens
When you see conversation history taking up most of it, you know you should compact or start a new session, to avoid Claude “forgetting” important details mentioned at the start of the session due to being cut off when context is full.
11. Slash Commands
Slash commands are shortcuts for tasks you run repeatedly — type / then the name, without needing to rewrite the long prompt each time.
---
name: review-pr
description: Review current diff against a standard checklist
---
Review the current code diff with a checklist:
1. Are there tests for the new logic?
2. Are there logs with sensitive information (card numbers, passwords)?
3. Are there violations of the constructor injection convention?
Answer in the format: PASS/FAIL for each item, with reasons.
Save this file to .claude/commands/review-pr.md, then call:
/review-pr
1. PASS - has PaymentServiceTest for refundPartial
2. FAIL - log.info contains order.getCardNumber() at line 58
3. PASS - uses constructor injection
Slash commands differ from skills in that: skills auto-activate based on context, while slash commands need you to call them by name explicitly — suited for fixed checklists like PR review, release notes.
12. Compaction
Compaction compresses a long conversation history into a summary, freeing up tokens without losing important information.
/compact
Before compact: 182,000 / 200,000 tokens
After compact: 24,000 / 200,000 tokens
Summary kept:
- Currently working on: adding refundPartial to PaymentService
- Completed: PaymentServiceTest (2 test cases pass)
- Remaining: update OpenAPI spec for the /refund endpoint
Instead of the agent completely forgetting history when context is full, compaction keeps important milestones (task in progress, completed, remaining) as a brief summary, then continues the session with context mostly empty. You should proactively call /compact after completing a major sub-task, before moving to the next one.
13. Subagents
Subagents let Claude Code spawn multiple child agents running in parallel, each handling an independent part of a large workflow.
---
name: test-writer
description: Specializes in writing unit tests for specified classes
tools: Read, Edit, Bash
---
You only write tests, don't modify business logic. Use JUnit 5 + AssertJ.
With this subagent file in .claude/agents/test-writer.md, you can assign a large task to the main agent, and the main agent will auto-distribute the work:
> Complete the refund module: add logic, write tests, update docs
[Main agent] Distributes work to 3 parallel subagents:
→ subagent "code-writer": add refundPartial to PaymentService
→ subagent "test-writer": write PaymentServiceTest
→ subagent "doc-writer": update README.md
[3 subagents running in parallel] ... completed in 42s
Instead of the main agent handling sequential steps (code → test → docs, which could take 3 times longer), subagents handle independent parts concurrently — useful for multi-step workflows that don’t depend tightly on each other.
When not to use: if the steps depend sequentially (for example, writing tests needs code to be done to know the interface), running in parallel will cause errors because the test subagent runs before the code exists. Only use subagents for tasks that can truly be separated independently.
14. Conclusion
The 12 features above divide into three clear groups: the agent guidance group (CLAUDE.md, Skills, Plan Mode), the safety control group (Permissions, Checkpoints, Hooks), and the capability extension group (MCP, Plugins, Subagents). Context, Slash Commands, and Compaction form the infrastructure layer that helps the agent run efficiently over a long session. You don’t need to use all 12 at once — start with CLAUDE.md and Permissions for your current project, then add Hooks or MCP when your workflow truly needs them.