Every time I start a new project, I spend the first 10 minutes setting up Claude Code properly. After doing this 20+ times, I've got it down to a repeatable system.
Here's the exact folder structure and config files I use.
The folder structure
your-project/
├── CLAUDE.md ← project memory
├── .claude/
│ ├── settings.json ← behavior rules
│ └── commands/ ← custom slash commands
│ ├── review.md
│ ├── test.md
│ └── deploy.md
└── src/
Step 1: CLAUDE.md — project memory
This is the most important file. Claude reads it at the start of every session.
# Project: [your project name]
## What this is
[One sentence description]
## Stack
- Language: Node.js 20
- Framework: Express
- Database: PostgreSQL
- Tests: Jest
## Key conventions
- Use async/await, never .then() chains
- All functions must have JSDoc comments
- Error handling: always throw, never return null for errors
- File naming: kebab-case.js
## What NOT to do
- Don't use var (ESLint will catch it)
- Don't commit .env files
- Don't write tests that hit the real database — use mocks
## Response style
- Short answers. No preamble.
- Show diffs, not full files, when making small changes
- If a change is > 50 lines, ask first
That last section (Response style) alone cuts my token usage by ~40%. Claude stops the "Great! I'll now refactor your..." preamble and just makes the change.
Step 2: .claude/settings.json — behavior rules
{
"permissions": {
"allow": [
"Bash(git:*)",
"Bash(npm:*)",
"Bash(node:*)",
"Bash(cat:*)",
"Bash(ls:*)",
"Bash(grep:*)"
],
"deny": [
"Bash(rm -rf *)",
"Bash(git reset --hard*)",
"Bash(git push --force*)"
]
}
}
The deny rules are non-negotiable after I learned the hard way. Claude Code can and will git reset --hard if you let it. Don't let it.
Step 3: Custom slash commands
These live in .claude/commands/ and become /project:review, /project:test, etc.
.claude/commands/review.md
Review the code changes since the last commit. Focus on:
1. Security issues (SQL injection, XSS, exposed secrets)
2. Logic errors that tests won't catch
3. Performance problems (N+1 queries, missing indexes)
4. Missing error handling
Format: bullet list, severity HIGH/MED/LOW prefix.
Don't comment on style — ESLint handles that.
.claude/commands/test.md
Look at the files changed since last commit.
Write Jest tests for any new functions that don't have coverage.
Rules:
- Unit tests only — mock all database calls
- Test the failure cases, not just happy path
- Put tests in __tests__/ next to the source file
.claude/commands/deploy.md
Pre-deploy checklist:
1. Run: npm test — stop if any failures
2. Check for console.log statements in src/ — list them if found
3. Verify .env.example is updated if .env changed
4. Check that migrations/ folder has no unrun migrations
Report what you found. Don't deploy anything automatically.
Step 4: One-liner setup script
I have this in my dotfiles:
#!/bin/bash
# claude-init.sh — run in any new project root
mkdir -p .claude/commands
# Copy base configs from template
cp ~/dotfiles/claude-templates/CLAUDE.md ./CLAUDE.md
cp ~/dotfiles/claude-templates/settings.json ./.claude/settings.json
cp ~/dotfiles/claude-templates/commands/* ./.claude/commands/
echo "✓ Claude Code configured. Edit CLAUDE.md with project specifics."
Run claude-init.sh, then spend 3 minutes editing CLAUDE.md with your actual stack and conventions. Done.
The payoff
With this setup:
- Claude never asks "what framework are you using?" because CLAUDE.md tells it
- Claude never does dangerous git operations because settings.json blocks them
-
/project:reviewbefore every PR takes 10 seconds - Token usage drops because response style rules cut the preamble
API cost note
If you're using Claude Code with direct Anthropic API keys, costs can add up fast with verbose responses. I run mine through SimplyLouie ($2/month flat rate) because the token savings from the CLAUDE.md response style rules become even more meaningful when you're not paying per token.
The configs above are in my public gist — link in comments.
What's in your CLAUDE.md? Drop your conventions below — I'm always looking to improve the template.
Top comments (1)
I'm pretty new to Claude Code so I'm giving your example a shot. My claude.md looks very clustered and I'm not sure if it makes things more complicated.