Stop Rewriting the Same Claude Code Prompts: Build Custom Slash Commands Instead
How reusable Claude Code commands can turn repetitive API scaffolding into a faster, cleaner developer workflow

The first time I used Claude Code seriously inside a project, I treated it like a very smart chat window.
I would type long prompts again and again:
- “Create a FastAPI router.”
- “Register it in the app.”
- “Follow the existing project conventions.”
- “Use the same formatting rules.”
- “Add CRUD routes.”
- “Don’t forget the schema.”
After a few rounds, I realised something uncomfortable.
- I was not automating my workflow.
- I was manually explaining the same workflow to an AI tool every single time.
That is where Claude Code custom slash commands started making sense.
Not because they look fancy.
- Because they solve a very real developer problem: repeated instructions.
The Problem: AI Helps, But Repeated Prompting Slows You Down
When you are building a backend, a lot of work follows patterns.
For example:
- Create a router
- Create a model
- Create schemas
- Add migrations
- Register everything in the app
- Follow project conventions
At first, asking Claude Code to do this manually feels fast.
But after the third or fourth time, the workflow becomes annoying. You are still copy-pasting instructions. You are still reminding the tool about folder structure. You are still explaining what “done correctly” means.
This is the gap custom slash commands fill.
Instead of writing a long prompt every time, you create a reusable command once.
Then you run something like:
/scaffold-router demoAnd Claude Code knows what to do.

What a Custom Slash Command Really Is
A custom slash command is basically a saved instruction file.
You place it inside your project under:
.claude/commands/For example:
.claude/commands/scaffold-router.mdThat markdown file becomes a command Claude Code can run from the slash command menu.
Here is a simplified version:
---
description: Create a new FastAPI router and register it
argument-hint: resource name
---
Create a new FastAPI router for $ARGUMENTS.
Use the existing API router structure.
Add:
- GET /
- POST /
- GET /{id}
- PATCH /{id}
- DELETE /{id}
Register the router in the main API router.
Follow the conventions in CLAUDE.md.
This command does three important things.
- First, it explains the goal.
- Second, it accepts an argument through
$ARGUMENTS. - Third, it tells Claude Code to follow the project’s existing rules.
That last part matters more than beginners expect.
Without project rules, AI tools often guess. And guessing inside a codebase is where small mistakes start.
The Useful Part: Commands Can Use Project Context
The interesting part is not just that the command saves text.
Claude Code can read files, inspect context, edit project files, and run commands depending on what you ask it to do.
So the command is not just a shortcut like a VS Code snippet.
It is closer to a repeatable workflow.
For example, a router scaffolding command can:
- Inspect existing routers
- Follow the same file structure
- Create the new router file
- Register it
- Remove demo code if needed
- Verify whether the app still works
This is where the workflow starts feeling less like prompting and more like building internal tools for your project.
A Practical Example: Scaffolding a Router
Let’s say your backend has a standard pattern for API resources.
Instead of manually creating every file, you define one command:
mkdir -p .claude/commands
touch .claude/commands/scaffold-router.mdThen you write the command:
---
description: Scaffold a new API router
argument-hint: resource name
---
Create a new router for $ARGUMENTS.
Follow the existing router pattern in the project.
Include these routes:
- GET list
- POST create
- GET by id
- PATCH by id
- DELETE by id
Register the router with the main application router.
Use the formatting and naming conventions already defined in CLAUDE.md.
Now, when you run:
/scaffold-router usersClaude Code has a clear, reusable instruction.
- No long prompt.
- No repeated explanation.
- Less chance of forgetting one step.
The Debugging Mistake I Did Not Expect
Here is a small detail that can waste time.
After creating the command file, the command may not appear immediately.
At first glance, it looks like the command is broken.
You may try:
/scaffold-router demoAnd Claude Code might say the command is unknown.
- The issue may not be your command content.
- It may simply be that Claude Code loaded commands when the session started.
So after adding a new command, restart Claude Code from the project root.
claudeThen try the slash command again.
This small detail makes a huge difference because otherwise, you start debugging the wrong thing.
Common checks:
pwd
ls -la .claude/commands
cat .claude/commands/scaffold-router.mdMake sure:
- You are inside the project root
- The folder name is
.claude/commands - The file uses
.md - Claude Code was restarted after adding the command
Going One Step Further: Let Claude Create Similar Commands
Once you create one good command, you do not need to manually write every similar command.
You can ask Claude Code to use the first command as a pattern and create others.
For example:
Using scaffold-router.md as the pattern, create custom slash commands for:
- new-model
- new-schema
- migrateThis is where the workflow becomes powerful.
You are not only using AI to generate application code.
You are using AI to improve the way you use AI inside the project.
That is a different level of productivity.
What Beginners Usually Miss
Custom commands are useful, but they are not magic.
A vague command gives vague results.
Bad:
Create backend files for $ARGUMENTS.Better:
Create a FastAPI router for $ARGUMENTS.
Follow the existing router structure.
Add all five CRUD routes.
Register the router.
Follow CLAUDE.md conventions.The better version reduces decision-making.
That is the main lesson.
AI tools perform better when we remove unnecessary ambiguity.
Tradeoffs: When Not to Use Custom Commands
Custom slash commands are great for repeated workflows.
But they are not always needed.
Use them when:

The cost is maintenance.
If your project structure changes, your commands may also need updates. A stale command can quietly generate old patterns.
So treat these commands like internal project docs. Review them when your architecture changes.
Reflection: What Changed After I Understood This
After using custom slash commands, I stopped thinking of Claude Code as only a coding assistant.
I started treating it like a programmable teammate.
That changed how I worked.
Instead of asking for isolated tasks, I started capturing repeatable workflows:
- how routers are created
- how files are named
- how conventions are followed
- how demo code should be removed
- how generated code should be checked
The unexpected realization was simple:
The real productivity boost is not from asking AI to write more code.
It is from teaching the AI your project’s repeated decisions once, then reusing them.
Most tutorials stop at “AI can generate code.”
But in real projects, consistency matters more than generation speed.
Key Takeaways
Custom slash commands in Claude Code are useful when you repeatedly perform the same project workflow.
They help you:
- Save repeated prompting time
- Keep code generation consistent
- Encode project conventions
- Reduce missed steps
- Build reusable AI-assisted workflows
Start small.
Create one command for a task you repeat often. Test it. Restart Claude Code if it does not appear. Then gradually add more commands as your project grows.
The goal is not to automate everything.
The goal is to stop explaining the same thing again and again.
And that is usually where a cleaner developer workflow begins.
From Dev Simplified
- 👏 Enjoyed the article? Don’t forget to leave a clap.
- 💬 Have thoughts or questions? Share them in the comments.
- ✍️ Want to write for Dev Simplified? Drop a personal note on any Dev Simplified story with your draft link.