DEV Community

brian austin
brian austin

Posted on

Claude Code project templates: start every session with a working scaffold

Claude Code project templates: start every session with a working scaffold

Every new Claude Code session starts the same way: you type create a new Express API and Claude asks 20 clarifying questions before writing a single line.

What if it just... knew what you wanted?

Project templates solve this. Here's how to build them.

The problem with blank-slate sessions

Without templates, every project starts with:

  • Explaining your stack preferences
  • Specifying your testing framework
  • Describing your folder structure conventions
  • Setting up the same boilerplate you always use

This wastes the first 10-15 minutes of every session.

The template approach

Create a templates/ directory in your project root with scaffold files Claude can copy and adapt:

.claude/
  templates/
    express-api/
      CLAUDE.md
      package.json.template
      src/
        index.js.template
        routes/index.js.template
        middleware/auth.js.template
    react-component/
      CLAUDE.md
      Component.jsx.template
      Component.test.jsx.template
      Component.css.template
    python-cli/
      CLAUDE.md
      main.py.template
      requirements.txt.template
Enter fullscreen mode Exit fullscreen mode

What goes in each template CLAUDE.md

The template CLAUDE.md is the key — it tells Claude exactly what decisions are already made:

# Express API Template

## Stack (already decided, don't ask)
- Runtime: Node.js 20
- Framework: Express 4
- Database: PostgreSQL via pg (not Prisma, not Sequelize)
- Auth: JWT via jsonwebtoken
- Validation: zod
- Testing: Jest + supertest
- Linting: ESLint + prettier

## Folder structure (follow exactly)
Enter fullscreen mode Exit fullscreen mode

src/
routes/ # one file per resource
middleware/ # auth, validation, error handlers
services/ # business logic (no DB calls here)
db/ # all database queries
utils/ # pure functions only


## Conventions
- All routes return { data, error, meta }
- Errors always include { code, message, field? }
- Auth middleware attaches req.user
- All DB functions are async and throw on error
- Tests use test database (TEST_DATABASE_URL env var)
Enter fullscreen mode Exit fullscreen mode

The activation slash command

Create .claude/commands/new-project.md:

# /new-project

Scaffold a new $ARGUMENTS project using the template at .claude/templates/$ARGUMENTS/

1. Read the template CLAUDE.md for conventions
2. Copy all .template files, removing the .template extension
3. Replace {{PROJECT_NAME}} with the actual project name
4. Replace {{PORT}} with an appropriate default port
5. Initialize git and create initial commit
6. Run npm install (or pip install -r requirements.txt for Python)
7. Confirm the scaffold is working by running the test suite
Enter fullscreen mode Exit fullscreen mode

Now you can type /new-project express-api and get a working scaffold in 60 seconds.

Parameterized templates

Templates get more powerful when they're parameterized. Use {{VARIABLE}} syntax:

// src/index.js.template
const express = require('express');
const app = express();

app.use(express.json());

const PORT = process.env.PORT || {{PORT}};

// Routes
app.use('/api/{{RESOURCE}}', require('./routes/{{RESOURCE}}'));

app.listen(PORT, () => {
  console.log(`{{PROJECT_NAME}} running on port ${PORT}`);
});
Enter fullscreen mode Exit fullscreen mode

Claude fills in the variables when you run /new-project.

Stack-specific templates worth creating

For frontend developers

# React Component Template

## Always create
- Component.jsx (functional, TypeScript props interface)
- Component.test.jsx (React Testing Library)
- Component.stories.jsx (Storybook)
- index.js (re-export only)

## Never do
- Class components
- PropTypes (we use TypeScript)
- Default export without named export
- Inline styles (use CSS modules)
Enter fullscreen mode Exit fullscreen mode

For API developers

# API Endpoint Template

## Every endpoint needs
- Route handler in src/routes/
- Input validation with zod schema
- Service function in src/services/
- Integration test in tests/
- OpenAPI doc comment

## Response format (never deviate)
Enter fullscreen mode Exit fullscreen mode


json
{
"data": {...} or null,
"error": null or {"code": "...", "message": "..."},
"meta": {"requestId": "uuid", "timestamp": "iso8601"}
}

Enter fullscreen mode Exit fullscreen mode


shell

The compound effect

After 3 months of using templates:

  • Claude knows your conventions without being told
  • New team members onboard to your standards automatically
  • Every project is structured identically
  • AI-generated code passes review first time

The template overhead is 30 minutes once. The savings are 10-15 minutes per session, forever.

Rate limits will find you eventually

Once you're running Claude Code heavily enough to use templates across multiple projects, you'll hit the rate limit wall — especially if you're scaffolding multiple services in parallel.

The standard fix is setting ANTHROPIC_BASE_URL to a proxy endpoint that gives you a fresh rate limit bucket.

I use SimplyLouie for this — it's ✌️$2/month and acts as a transparent Claude API proxy. You set it once:

export ANTHROPIC_BASE_URL=https://simplylouie.com/api/proxy
Enter fullscreen mode Exit fullscreen mode

And Claude Code routes through it without any other changes. No rate limit interruptions mid-scaffold.

Start with one template

Don't build 10 templates at once. Pick the project type you create most often and build one template this week. Run it for a month. Then add the next one.

The best template is the one you actually use.


Want Claude Code running without rate limit interruptions? SimplyLouie is ✌️$2/month — 7-day free trial, no commitment.

Top comments (0)