A Claude Code Setup for Serious Coding Work
A dependable Claude Code setup combines a short project CLAUDE.md with working commands and constraints, permissions that allow routine tools, a capable model for complex work and a faster one for simple tasks, a few focused MCP servers including retrieval over your docs and code, and habits: small tasks, fresh sessions, tests first, and reviewing every diff.
Model choice
Use a highly capable model for tasks that need reasoning across many files: architecture changes, difficult debugging, and refactors. Use a faster, cheaper model for routine work such as small edits, test scaffolding, and explanations. Switching per task, rather than running everything on the largest model, keeps costs and latency reasonable without giving up quality where it matters.
Project memory and permissions
Write a short CLAUDE.md: how to build, test, and lint; conventions the code does not make obvious; and hard rules such as never editing generated files. Configure permissions so the test runner, linters, and read-only commands run without prompts, while anything destructive or external still asks. Commit both so every teammate and every session starts the same way, and review them like code.
Tools and context
Add MCP servers sparingly. A retrieval server over your documentation, architecture notes, decision records, and codebase is the most valuable, because it lets the agent find the relevant three chunks instead of reading forty files or guessing. An issue tracker integration helps if you work from tickets. Each additional server adds tool definitions to context, so remove ones you do not use.
Habits that keep sessions reliable
- Small tasks. One feature slice, one bug, one refactor at a time.
- Tests first. Write or approve tests before implementation so the agent has an objective target.
- Fresh sessions. Start a new session for each task, and restart when a session drifts or fills with stale context.
- Commit at green. Commit whenever tests pass, so a bad turn costs minutes, not an afternoon.
- Review every diff. Read changes as you would a colleague's pull request, especially around data, security, and public interfaces.
Automation that pays off
A hook that formats and lints after each edit removes a whole class of review comments. A custom command for your review checklist makes reviews consistent. A command that prepares a pull request description from the diff saves time on every change. Build these after you notice yourself repeating the same instruction, not before. Each piece of automation is also something to maintain, so keep the ones that earn their place and delete the rest.
Security defaults
A good setup is also a safe one. Keep secrets out of the files and environment the agent can read, or scope them narrowly. Deny commands that touch production or external systems unless explicitly approved. Review MCP servers before installing them, since each runs with its own access. And be cautious with content the agent reads from outside, such as issues, web pages, or dependencies, because instructions hidden in that content can steer it.
Working as a team
When several developers use Claude Code on one repository, consistency matters more than any individual's preferences. Commit the shared CLAUDE.md, permissions, commands, and MCP configuration. Agree on how agent-written changes are reviewed and labelled. Share improvements to the setup through normal pull requests, so the whole team benefits from each fix instead of each person maintaining a private configuration that drifts.
Watching cost and context
Long sessions accumulate context, which raises cost and can reduce focus. Use compaction or clear the session when switching topics, keep CLAUDE.md lean, and lean on retrieval rather than pasting large documents. Check usage periodically; a few habits, such as fresh sessions and smaller tasks, usually cut cost more than any single setting.
Frequently asked questions
- What is the best Claude Code setup?
- One that fits your codebase: a short CLAUDE.md with commands and constraints, permissions for routine tools, task-appropriate model choice, a retrieval server over your docs and code, and disciplined habits such as small tasks, tests first, fresh sessions, and reviewing every diff. Add automation only when you notice repetition.
- Which MCP servers should I add to Claude Code first?
- Start with whatever replaces information you currently paste into prompts, usually documentation, architecture notes, and the codebase itself through a retrieval server. Add an issue tracker integration if you work from tickets. Keep the list short, since every server adds tool definitions to the agent's context.
- How do I stop Claude Code sessions from drifting?
- Keep tasks small, start a fresh session for each new task, restart when the agent repeats mistakes or loses track, and commit whenever tests pass. Long sessions accumulate stale assumptions and context. A clean session with a clear task and good retrieval usually outperforms a long one with more history.
- Should Claude Code have access to production?
- Generally not by default. Keep production credentials out of the agent's environment, deny commands that touch production systems, and route any production change through your normal deployment and review process. If an agent needs read access for debugging, scope it narrowly, log it, and prefer read-only replicas or observability tools over direct access.
- How often should I start a new Claude Code session?
- At least for each new task, and whenever the session starts repeating mistakes, ignoring earlier decisions, or filling with unrelated history. Starting fresh is cheap, especially with a good CLAUDE.md and retrieval, while carrying stale context through a long session tends to cost more tokens and produce worse results.