From using the tool to shaping it
So far you’ve used Claude Code as it ships. Its real power for a team is that it’s programmable: you can encode your workflows as commands, teach it specialized roles, hook it into your toolchain, and connect it to external systems. Everything here lives in your repo as plain files — versioned and shared like any other config.
Custom slash commands
A slash command is a reusable prompt. Create a markdown file in .claude/commands/ and its name becomes the command. This is the fastest win: any prompt you type more than twice should become a command.
.claude/commands/test-class.md:
---
description: Write JUnit 5 + AssertJ tests for a class
argument-hint: <FullyQualifiedClassName>
---
Write thorough JUnit 5 tests for `$ARGUMENTS`, matching the AssertJ
style used elsewhere in this repo. Cover the happy path, boundaries,
and failure modes. Mock collaborators with Mockito but use real value
objects. Run the tests and confirm they pass.
Now /test-class com.acme.PriceCalculator runs that whole workflow. $ARGUMENTS carries what you typed after the command. Commit these to .claude/commands/ and your whole team shares the same vocabulary; put personal ones in ~/.claude/commands/.
Skills: capabilities Claude reaches for on its own
A skill is like a slash command that Claude can reach for on its own when a task matches it — you don’t have to remember to call it. A skill is a folder under .claude/skills/ containing a SKILL.md with a name and a description. Claude weighs that description against the task at hand to decide whether the skill is relevant, so write the description in terms of when to use it; you can also invoke one explicitly if you want.
.claude/skills/spring-rest-endpoint/SKILL.md:
---
name: spring-rest-endpoint
description: >
Use when adding a new REST endpoint to this Spring Boot service.
Enforces our controller→service→repository layering, DTO mapping,
validation, and OpenAPI annotation conventions.
---
When adding a REST endpoint in this project:
1. Controller in `adapters/web`, returning a DTO, never an entity.
2. Bean Validation on the request DTO; map errors via our
`ApiExceptionHandler`.
3. Business logic in a `@Service`; the controller only adapts.
4. Add/extend the OpenAPI annotations and a `@WebMvcTest`.
... (a skill can include reference files and scripts in its folder too)
The difference from a slash command: you invoke a command; Claude chooses a skill based on its description. Skills are the right home for codified, repo-specific know-how — your team’s “how we always do X.”
Subagents: specialized roles
You met subagents for parallel migrations in Module 6. You can also define named ones in .claude/agents/ with their own focus, tools, and even model. A subagent runs in its own context and reports back, which keeps the main session uncluttered.
.claude/agents/test-writer.md:
---
name: test-writer
description: Writes and runs JUnit 5 tests. Use proactively after
new logic is added that lacks coverage.
tools: Read, Edit, Bash
---
You are a meticulous Java test engineer. Given a class, you write
JUnit 5 + AssertJ tests covering happy paths, boundaries, and
failure modes, run them, and iterate until green. You never weaken a
test to make it pass. You report a short coverage summary.
A focused subagent like this, restricted to the tools it needs, is both safer and more reliable than a general session for repetitive specialist work — and the critic style of agent (one whose only job is to find problems with a change) is a particularly effective pattern for review.
Hooks: automate the boring guarantees
Hooks are shell commands Claude Code runs automatically on lifecycle events — configured in settings.json. They turn conventions you hope people follow into things that simply happen. The killer example for Java: auto-format after every edit, so Claude’s diffs always match your style.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "./gradlew spotlessApply -q"
}
]
}
]
}
}
Now every file Claude edits is run through Spotless (or google-java-format) before you ever see the diff — no more “please reformat” round-trips. Other useful Java hooks: run a quick compileJava after edits to catch breakage immediately, or a PreToolUse hook that blocks edits to generated sources. Because hooks are deterministic shell commands, they enforce guarantees the model can’t forget.
Tip: Hooks run real commands with your permissions on your machine. Review any hook before committing it, and keep them fast — a hook that runs the full integration suite after every edit will make every turn painful. Format and compile are good; full Testcontainers runs are not.
MCP: connect external systems
The Model Context Protocol (MCP) lets Claude Code talk to external tools and data sources through a standard interface — databases, issue trackers, internal services. You add a server once and its tools become available in your sessions.
# A local stdio server (example shape):
claude mcp add my-db -- npx -y @some/postgres-mcp-server
# A remote HTTP server:
claude mcp add --transport http github https://your-mcp-host/github
For a Java team, useful connections include a database MCP (so Claude can inspect your real schema when writing a JPA query or a Liquibase changeset, instead of guessing), an issue-tracker MCP (turn a ticket into a branch and a draft change), and your CI or observability systems. The point is to give the agent grounded access to the systems your code actually runs against.
Security note: an MCP server runs with whatever access you give it. Connect a read-only replica, not your production primary, and never wire an agent to a system where an unreviewed action could do real damage. Treat MCP credentials like any other production secret.
What just happened
You can now reshape Claude Code into a teammate that fits your stack: commands and skills that encode your conventions, specialized subagents, hooks that make formatting and compilation automatic, and MCP connections to the systems around your code. The last module turns all of this into a team practice.
Key takeaways
- Slash commands (
.claude/commands/) are reusable prompts you invoke; skills (.claude/skills/) are capabilities Claude invokes itself based on their description. - Define subagents (
.claude/agents/) for focused, tool-restricted roles like test-writing or critique. - Hooks in
settings.jsonmake guarantees deterministic — auto-format with Spotless on every edit is the standout Java win. - MCP servers connect Claude to databases, trackers, and services — use read-only, least-privilege access.
- All of this is plain files in the repo: version it, review it, share it.