Contents
A strong developer joining your team writes decent code on day one. What they don’t know yet is how the project works: where things live, which conventions matter, which files nobody should touch. Claude Code is in the same spot right after you install the VS Code extension.
Even without any setup it takes a lot of routine work off your plate. You can treat it like a developer working under supervision. It refactors, upgrades libraries and frameworks, generates tests, updates documentation after code changes and reviews your code before a commit. In a production project, though, you want that work to be reliable, and for that Claude Code has to learn the project the way a new hire would.
The chat window#
At the top there’s the session title (“Untitled” until the session starts) and buttons for session history and a new session. The chat area sits in the middle with the prompt input below it. Along the bottom of the input, from left to right: attachments, the command picker, the file currently open in the editor (or the lines you selected), the current permission mode and the submit button.
Most of the time you just type a request, pretty much as you would to another developer:
Refactor this component
Upgrade Next.js to the latest version
Fix TypeScript errors
Generate Playwright tests for this page
Review current git diff
While it works, the chat shows every step: what Claude is analyzing, which files it reads, which commands it runs and what it changes. Edits, shell commands and package installs may need your approval, depending on the permission mode. When it’s done, Claude usually explains what it changed, mentions the decisions it made and sometimes suggests follow-up improvements or things to check by hand.
You can attach screenshots, logs, stack traces, design mockups or spec documents to a request. That helps a lot with UI fixes, debugging and turning designs into components. The command picker lists built-in commands, and the mode switch sets how much autonomy Claude gets in the current session.
Where the configuration lives#
That’s enough to get going. To make Claude Code reliable, you configure it inside the project. A fairly common layout looks like this:
your-project/
├── CLAUDE.md # team instructions (committed)
├── CLAUDE.local.md # your personal overrides (gitignored)
│
└── .claude/
├── settings.json # permissions + config (committed)
├── settings.local.json # personal permission overrides (gitignored)
│
├── commands/ # custom slash commands → /name
│ ├── review.md
│ ├── fix-issue.md
│ └── deploy.md
│
├── rules/ # modular instruction files (loaded conditionally)
│ ├── code-style.md
│ ├── testing.md
│ └── api-conventions.md
│
├── skills/ # auto-invoked multi-step workflows
│ ├── security-review/
│ │ └── SKILL.md
│ └── deploy/
│ └── SKILL.md
│
├── agents/ # specialized subagents with isolated context
│ ├── code-reviewer.md
│ └── security-auditor.md
│
└── docs/ # reference docs that skills pull in on demand
└── architecture.md
~/.claude/ # global (applies to ALL your projects)
├── CLAUDE.md
├── settings.json
├── commands/
├── skills/
└── agents/
Shared team settings get committed, personal overrides stay gitignored, and ~/.claude/ holds whatever should apply to all your projects.
Keeping secrets away from Claude#
Before anything else, keep sensitive data out of Claude’s reach. Does Claude ask before it opens a file? Not inside the working directory. File reads there need no approval at all (permissions docs), so a .env in the project root is fair game unless you deny it explicitly. And whatever you approve with “don’t ask again” is remembered. So we deny access to secrets in .claude/settings.json:
{
"permissions": {
"deny": [
"Read(.env*)",
"Edit(.env*)",
"Read(*.pem)",
"Edit(*.pem)",
"Read(*.key)",
"Edit(*.key)",
"Read(*.p12)",
"Edit(*.p12)",
"Read(*.pfx)",
"Edit(*.pfx)",
"Read(*.crt)",
"Edit(*.crt)",
"Bash(*.env*)",
"Bash(*.pem*)",
"Bash(*.key*)",
"Bash(*.p12*)",
"Bash(*.pfx*)",
"Bash(*.crt*)",
"Bash(*.csr*)",
"Bash(*id_rsa*)",
"Bash(*id_ed25519*)",
"Bash(*id_dsa*)",
"Bash(printenv*)"
],
"allow": [
"Bash(grep -E \"\\\\.\\(ts|tsx|js|jsx\\)$\")"
]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Read|Edit|Write",
"hooks": [
{
"type": "command",
"command": "bash .claude/hooks/block-sensitive-files.sh",
"statusMessage": "Checking for sensitive file access..."
}
]
}
]
}
}
The deny list keeps Claude from reading or editing files that usually hold secrets, and from running shell commands that touch them. If you wonder why there are no Write(...) entries: Edit rules apply to every built-in tool that writes files, and Write(path) rules don’t match anything. Bare patterns like .env* follow gitignore semantics, so in a deny rule they match at any depth below the project root.
The config also registers a hook as a second line of defense. It runs before every Read, Edit and Write call and blocks the ones aimed at sensitive files:
File: .claude/hooks/block-sensitive-files.sh
#!/usr/bin/env bash
input=$(cat)
path=$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty')
[[ -z "$path" ]] && exit 0
if printf '%s' "$path" | grep -qE '(\.env([^/]|$)|\.pem$|\.key$|\.p12$|\.pfx$|\.crt$|\.csr$|id_rsa$|id_ed25519$|id_dsa$)'; then
printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Access to sensitive file blocked by security policy"}}'
fi
The hook gets the tool call as JSON on stdin, pulls out file_path with jq (so you need jq installed) and prints a deny decision when the path looks sensitive. It still exits with 0, which is what Claude Code expects from a hook that returns JSON (hooks docs).
Choosing a permission mode#
Sometimes you want Claude to only analyze the project, sometimes to edit freely, sometimes something in between. The VS Code extension has “Ask before edits”, “Edit automatically”, “Plan mode” and “Auto mode” for that (newer versions call the first one “Manual”). Shift+Tab switches between them.
For small fixes and everyday work, “Ask before edits” is comfortable enough. Claude reads the code, proposes changes and asks before it modifies files or runs commands. For repetitive work like generating tests, fixing lint errors, updating imports or mechanical refactoring, “Edit automatically” saves a lot of clicking, since you don’t approve every single step.
The menu describes “Auto mode” as Claude choosing the best mode for each task. What actually happens is that a classifier reviews actions instead of asking you, and blocks anything that goes beyond your request, targets infrastructure it doesn’t recognize or looks driven by hostile content. Read-only actions and file edits in the working directory go through without the classifier (permission modes).
For larger tasks, especially when the changes will touch several files or several parts of the architecture, I prefer “Plan mode”. There Claude acts more like a technical analyst. It reads files, explores the codebase, follows dependencies and asks clarifying questions. It may run shell commands to explore (read-only ones run freely, anything else still asks), but it doesn’t edit your source. What you get is an implementation plan as a Markdown document you can review.
By default plans are stored in:
~/.claude/plans/
The plansDirectory setting changes that. It works in any settings file, .claude/settings.json included, and resolves relative to the project root.
I use plan mode for framework migrations, larger refactorings, security audits, feature planning, anything where I want to see the scope before letting Claude change things. Plans aren’t tied to a chat session either. Later, in a completely different session, you can ask Claude to continue from a plan:
Follow implementation plan from:
~/.claude/plans/nextjs-migration.md
Start from phase 1 and stop before running tests.
Or simply:
Implement the plan from plans/auth-refactoring.md
That way a big task splits into a review stage and an execution stage.
CLAUDE.md: standing project context#
CLAUDE.md is a standing agreement between you and the model. You can put it in the project root, in a subdirectory (say ./src/app/api/) or in ~/.claude/ for all your projects. The one in the project root, along with any in parent directories, is loaded into context at launch. A CLAUDE.md in a subdirectory loads only once Claude reads or edits a file in that subdirectory (memory docs).
There’s no need to write it from scratch. Run /init and Claude generates a CLAUDE.md from the actual codebase. Then extend it with your own conventions. For example, I don’t want generated UI copy, notifications or release notes to read like AI output, so I describe the style I expect:
File: ./CLAUDE.md
## Human-Like Writing Style
When generating any user-facing text (UI copy, notifications, emails, release notes):
- No em dashes (`—`)
- No AI filler: "It looks like...", "Please note that...", "Here's what happened..."
- No motivational/empathetic padding unless explicitly requested
- Mix short and medium sentences; avoid perfectly symmetrical structures
- Write like an experienced engineer, not a customer-support bot
Prefer: `Your verification link expired.`
Avoid: `It looks like your verification link may have expired before you had a chance to use it.`
This is a short version of what I keep in the repository of this blog.
Rules#
Rules live in .claude/rules/ and work like a CLAUDE.md split into modules. A rule without paths frontmatter loads at launch, with the same priority as .claude/CLAUDE.md. Add paths and it loads only when Claude works with matching files. Let’s write one for AI code reviews:
File: .claude/rules/diff-review.md
# AI Review Rules
Be critical and suspicious.
Assume subtle bugs exist.
Focus on:
## Architecture
- accidental architectural regressions
- violations of Next.js 15/16 best practices
- unnecessary abstractions
- over-engineering
- hidden coupling
- server/client boundary mistakes
## React
- hydration risks
- unstable rendering behavior
- unnecessary useEffect usage
- derived state in effects
- stale closures
- memoization misuse
- unnecessary client components
- React 19 anti-patterns
## Next.js
- SSR issues
- cache invalidation mistakes
- async server component mistakes
- route handler edge cases
- misuse of server actions
- improper loading/error boundaries
## Security
- auth/token leakage risks
- unsafe HTML rendering
- upload validation issues
- SSR data exposure
- missing permission checks
## Code Quality
- unnecessary complexity
- dead code
- weak naming
- hidden side effects
- duplicated logic
- weak error handling
Do you have to reference it from CLAUDE.md for it to load? No. Every .md file under .claude/rules/ is picked up automatically, and since this one has no paths, it’s in context in every session. But “Be critical and suspicious” is meant for reviews, not for writing code, so I’d say in CLAUDE.md when it applies:
## Code Review
When reviewing code, apply the rules in `.claude/rules/diff-review.md`.
Claude then uses these criteria whenever you ask for a review, the bundled /code-review skill (alias /review) included. You can also point to the rule explicitly at any time:
Review the current diff.
Apply all rules from `.claude/rules/diff-review.md`.
Commands#
A custom slash command is a Markdown file with a prompt in it. This one runs a review against the rule above:
File: .claude/commands/diff-review.md
Run `git add -N . && git diff HEAD > .claude/current.diff` in the shell, then review `.claude/current.diff` using the rules in `.claude/rules/diff-review.md`.
git add -N (intent to add) is what makes newly created files show up in git diff HEAD, so the diff covers everything since the last commit. It’s saved to .claude/current.diff, and Claude reviews it with the rules from .claude/rules/diff-review.md. Two side effects to know about: new files stay marked as intent-to-add in the index, and you’ll want .claude/current.diff in .gitignore.
Once the file exists, /diff-review appears in the command list and runs the whole thing.
Why not make it a skill? You can, and that’s the recommended way now. Custom commands have been merged into skills. Files in .claude/commands/ keep working, but for anything new the docs prefer a skill, and if a skill and a command share a name, the skill wins (slash commands docs).
Skills#
Skills are reusable instruction sets for specific tasks and workflows. Only a skill’s description stays in context all the time. The body loads when the skill is used, either because you typed /name or because Claude decided the skill fits the task. That makes them cheaper on tokens than rules, which load in full at launch. If you don’t want Claude to pick a skill on its own, set disable-model-invocation: true in its frontmatter (skills docs).
Skills suit repeatable multi-step procedures: code reviews, audits, release preparation, documentation, testing workflows, anything you keep asking Claude to do over and over again. A skill is a folder under .claude/skills/ with a SKILL.md inside:
File: .claude/skills/summarize-changes/SKILL.md
---
name: summarize-changes
description: Summarizes uncommitted changes and flags anything risky before committing
---
# Summarize Changes
When this skill is invoked:
1. Run `git diff` to see all uncommitted changes
2. Group changes by type: new features, bug fixes, refactors, deletions
3. Write a short human-readable summary (3–5 bullet points max)
4. Flag any changes that look risky:
- Deleted files or functions
- Changes to auth, payments, or security-related code
- Large diffs with no obvious purpose
5. Suggest a conventional commit message based on the summary
Keep the tone concise. No need to list every file, focus on intent and risk.
Now the skill can be called from the prompt input as a slash command:
/summarize-changes
Over time a team collects its own library of workflows like this, tailored to the project.
You don’t have to write all of them yourself. There are community collections such as awesome-agent-skills. One skill I use quite often is Addy Osmani’s web quality audit. It runs a fairly thorough audit based on Lighthouse checks, covering performance, accessibility, SEO and general best practices. For frontend projects it’s a practical way to automate routine quality reviews without leaving Claude Code.
Agents#
Claude Code also supports custom agents, also called subagents. Each one has its own system prompt, tool permissions and model preference, and runs in a separate context window. When Claude decides a task fits one of them, it delegates the work.
File: .claude/agents/security-auditor.md
---
name: security-auditor
description: Expert security reviewer. Use PROACTIVELY after changes to auth or data handling.
tools: Read, Grep, Glob
model: opus
---
You are a senior security engineer. Check for OWASP Top 10 vulnerabilities...
tools limits what the agent can do. This security auditor can read and search the codebase, and that’s it, no edits and no commands. model picks the model for the job. Lightweight agents often do fine on Haiku, while deeper analysis may need Sonnet or Opus.
You can also call an agent explicitly. Type @ and pick it from the list, or write the mention by hand:
@agent-security-auditor audit the auth module for vulnerabilities
That skips automatic routing and sends the task straight to the agent. Just naming it in the prompt (“use the security-auditor subagent to…”) usually works too (subagents docs).
Community-maintained subagents are collected in the VoltAgent Awesome Claude Code Subagents repository.
Rules, skills or agents?#
A rule is a guideline, a skill is a procedure, an agent is a specialist role.
| What it defines | Typical uses | |
|---|---|---|
| Rule | how Claude should behave | coding standards, architecture requirements, security guidelines, review checklists |
| Skill | a repeatable multi-step workflow | reviewing changes, preparing releases, generating documentation, auditing code, analyzing logs |
| Agent | a specialist with its own instructions, permissions and model | security reviews, performance audits, accessibility checks, architecture analysis |
A mature setup usually has all three. None of it hands the engineering decisions to the AI. What you get is less repetitive work, team conventions that actually hold and fewer context switches, and a few hours of configuration pay off quickly across daily development, code reviews, migrations and maintenance.
If I were setting this up from scratch, I’d go in this order. Deny rules and the hook first, before Claude ever opens the project. Then /init and a CLAUDE.md with your conventions. Rules and commands next, once you know what a review should look for. Skills and agents last, when you notice you keep typing the same prompt.