Skip to content

Claude Code Mastery4 / 12

Slash Commands — Building a Project from A to Z

/init, /agents, /compact and your own custom commands. The toolkit that lets you go from empty folder to running app without leaving the Claude prompt.

Slash commands are the hidden superpower of Claude Code.

Most people use /init, then forget the system exists. That is leaving 80% of the productivity on the table.

Used right, slash commands turn Claude Code into an opinionated CLI: one keystroke = one repeatable workflow. Let's walk through the built-ins, then build a project from empty folder to running app using nothing but slash commands.

The four built-ins worth knowing

/init

Run this once per project. It creates .claude/ with settings.json, CLAUDE.md, and agents/. Without it, every session starts cold.

/agents

Opens the sub-agent picker. Sub-agents are specialized Claude personas (we cover the full set in Article 5). Use /agents to invoke code-reviewer, test-writer, migration-runner etc. without retyping their system prompts.

/compact

The most underrated. As a session grows, the context window bloats with old tool calls and discarded files. /compact re-summarises the conversation while keeping decisions intact.

/clear

Nuclear option. Drops the entire history. Useful when you switch from "implementing feature X" to "debugging unrelated CI failure" — fresh context, fresh attention.

Custom commands — the real game

Custom commands live in .claude/commands/<name>.md. They are just markdown files that get pasted into the conversation when you type /<name>.

Example: /feature

.claude/commands/feature.md:

You are about to implement a new feature.

Use this template:

# Goal
{{describe the outcome with a number where possible}}

# Constraints
- Do not break existing tests.
- Do not add a new dependency without asking.
- Keep changes scoped to the listed files.

# Definition of Done
- pnpm test passes.
- pnpm lint clean.
- Add a PR description (1 paragraph).

# Files
{{list the relevant files}}

Wait for the user to fill the blanks before starting.

In your terminal:

> /feature

Claude Code expands it. You fill the blanks. Now your prompt structure is enforced — every feature gets the same shape.

Example: /test-and-fix

.claude/commands/test-and-fix.md:

1. Run `pnpm test`.
2. If failures: read each failing test, infer the bug, fix the code (not the test), rerun.
3. Stop only when `pnpm test` exits 0.
4. Report a 3-line summary of what was changed.

Now /test-and-fix is a one-keystroke "go fix the build" command. Beautiful for triaging a flaky CI.

Example: /release-notes

.claude/commands/release-notes.md:

1. `git log --oneline ${LAST_TAG}..HEAD`
2. Group commits into: features / fixes / chores.
3. Write a changelog entry in markdown, no fluff, max 25 lines.
4. Save to CHANGELOG.md and stage it.

A to Z — building a project with only slash commands

Let's prove the point. We are going to scaffold a small Next.js + tRPC service from an empty folder, with one rule: no manual code edits, only slash commands and prompts.

mkdir todo-service && cd todo-service
claude

Inside Claude:

> /init

→ Creates .claude/ and asks for a CLAUDE.md. Fill it:

# Project context
- Small Next.js 14 + tRPC + drizzle service for todos.
- TS strict, pnpm, vitest.

# Conventions
- Test: pnpm test
- Lint: pnpm lint
- Format: pnpm fmt

# Definition of done
- Tests pass, lint clean, no console.log in src/.

Then:

> /feature
> Goal: Bootstrap Next.js 14 app with tRPC + drizzle (sqlite) and a todos table.
> Constraints:
>   - pnpm only.
>   - Use the official create-next-app + tRPC starter, not a fork.
>   - Strict TS.
> Definition of Done:
>   - pnpm dev runs.
>   - GET /api/trpc/todos.list returns [].
> Files: (empty repo)

Claude scaffolds, installs, runs the dev server, hits the endpoint to verify, returns a diff.

> /feature
> Goal: Add POST todos.create with zod validation, persist to drizzle.
> Constraints:
>   - Reuse drizzle client in lib/db.ts.
>   - 1 vitest covering create + list.
> Definition of Done:
>   - vitest green.
>   - typecheck clean.
> Files: src/server/api/routers/todos.ts, lib/db.ts

Claude writes the procedure, the schema, the test, runs it, returns a diff.

> /test-and-fix

If anything broke, it fixes it.

> /release-notes

Changelog written.

> git checkout -b feat/todos && git add . && git commit -m "feat: todos.create + list"

You did not open a single file. The diff is reviewable; the work is done.

Anti-patterns

  • /feature without filling the blanks. Defeats the purpose; the agent guesses.
  • Custom commands that just echo a paragraph. A custom command should encode a workflow (steps, checks), not just a tone.
  • Storing slash commands outside the repo. Commit .claude/commands/ so the team gets the same vocabulary.

The team angle

When .claude/commands/ is in git, you are essentially shipping shared muscle memory. New hires inherit your /feature, /review, /release-notes for free. After 3-4 weeks every team I've worked with has 8-12 custom commands and onboarding time on Claude Code drops from "a week" to "a morning."


Next article: Sub-Agents — The 11 Specialized Experts Inside Claude Code. Slash commands let you reuse prompts. Sub-agents let you reuse whole personas. That is the unlock.

Share this article

#ClaudeCode #DevTools #Productivity #AgenticAI #Automation

LinkedInX / TwitterBlueskyThreadsRedditHacker NewsWhatsAppEmail

Series — Claude Code Mastery

  1. Part 01Claude Code vs ChatGPT vs Copilot vs AgentsMost developers are using the wrong AI tool for the wrong job. Here is why — and what to do instead.
  2. Part 02Installation + The Antigravity WorkflowInstalling Claude Code is a 30-second job. Setting up the workflow that makes the agent feel like it's doing the heavy lifting — that's the part nobody writes about.
  3. Part 03Writing Prompts That Work"Make it better" is not a prompt. "Refactor this for performance" is not a prompt. Here is the four-part structure that makes Claude Code actually finish what you asked.
  4. Part 04Slash Commands — Building a Project from A to Zyou are here/init, /agents, /compact and your own custom commands. The toolkit that lets you go from empty folder to running app without leaving the Claude prompt.
  5. Part 05Sub-Agents — The 11 Specialized Experts Inside Claude CodeSlash commands reuse prompts. Sub-agents reuse whole personas — code-reviewer, test-writer, migration-runner. Here is the team you should have on day one.
  6. Part 06Production Codebase SafetyPermissions, guardrails, and what not to automate. The unsexy article that decides whether Claude Code becomes infrastructure or becomes the reason you got paged at 2 AM.
  7. Part 07Multi-Agent PipelinesChaining sub-agents, running them in parallel, and the patterns for 'review-while-coding' without losing your mind. Where Claude Code starts to feel like a small engineering org.
  8. Part 08Building Complete FeaturesFrom Linear ticket to merged PR with Claude Code. A real, honest walk-through — what the prompt looked like, what the agent got right, what I caught in review.
  9. Part 09Testing and DebuggingLetting Claude Code own the entire test loop. Including the parts that make engineers nervous: regressions, flakies, integration tests, and the stack-trace whisperer.
  10. Part 10Team WorkflowsHow engineering teams are actually integrating Claude Code today. The shared .claude/ folder, the review rituals, and the anti-patterns I keep seeing in the wild.
  11. Part 11Advanced Patterns — Hooks, MCP Servers, Custom Tools, System PromptsOnce you've outgrown the defaults: hooks for deterministic side effects, MCP servers for org-specific data, custom tools, and system-prompt surgery.
  12. Part 12The Future of Agentic DevelopmentWhere this is going in 2026 and beyond. What I'd bet on, what I would not, and the line where I get sceptical of the hype.

Keep learning

Skill in the catalogue

prompt-engineer

Transforms user prompts into optimized prompts using frameworks (RTF, RISEN, Chain of Thought, RODES, Chain of Density, RACE, RISE, STAR, SOAP, CLEAR, GROW)

Open the skill →

Course

The Claude Mastery course

12 modules · 5 languages · certificate · 3-day free trial.

See plans →
LinkedInX / TwitterBlueskyThreads