I’ve been using Claude Code more and more for building tooling. The code it produces works — but “works” and “would survive a production incident at 2 AM” are very different standards. The stuff I deal with at work — tenant isolation, structured logging, secrets management, proper error handling, observability, test coverage that actually catches real failures — Claude Code doesn’t do any of that by default. It’ll happily hardcode a connection string, skip tenant scoping on a query, swallow an exception, or write tests that only cover the happy path. So I built a claude.md template that tries to fix that. What it does It’s a set of rules that Claude Code loads automatically, structured around pillars like security, data privacy, testing, observability, error handling, API design, and database practices. Each pillar has: DO rules — what good practice looks like DO NOT rules — the most common shortcuts that cause real problems (these are honestly more valuable than the DOs) REQUIRE rules — things Claude Code can’t do itself (no secrets manager configured? no auth provider? no log aggregation?) where it should flag the gap to you instead of silently working around it Key design decisions Context window is precious. Every word in claude.md competes with your actual conversation. So the root file is ~70 lines — just the critical rules that prevent the worst outcomes. Detailed guidance lives in pillar files under docs/standards/ that Claude Code reads on demand when working in that domain. This minimises the amount that ends up in your context window. Three-tier responsibility model. Not everything can be done by Claude Code. We split things into: (1) Claude Code does it (in-code practices), (2) Claude Code scaffolds it but you operationalise it (Dockerfiles, CI configs, IaC templates), and (3) you do it (secrets infrastructure, compliance decisions, incident response). The template makes Claude Code flag when it hits a tier 3 dependency instead of inventing a workaround. AWS MCP is read-only. This was a late decision but an important one. One of the opinions in the package is ‘use cheap AWS serverless components where doing so is simpler than standing up your own’ for things like message queues, pubsub etc. Giving Claude Code write access to AWS via MCP is essentially handing it a credit card. The template recommends connecting AWS MCP with read-only credentials and having Claude Code propose all changes as CloudFormation templates with a cost summary. No accidental resource creation, no surprise bills. There’s a whole cost traps list (NAT Gateways, unattached EIPs, CloudWatch Logs with no retention policy, etc.). Tailoring prompt included. The template isn’t one-size-fits-all. A CLI tool doesn’t need tenant isolation. A static site doesn’t need correlation IDs. So there’s a prompt you run at the start that tells Claude Code to assess which pillars are relevant to your project, strip out what doesn’t apply, remove irrelevant compliance references, and check for outdated advice. Pre-production checklist prompt. As you build, Claude Code flags missing external dependencies. Before going to prod, there’s a prompt that reviews all the REQUIRE and FLAG items and produces an addressed/not-addressed/not-applicable checklist. MCP server recommendations with risk warnings. We mapped out which “user must do” items can be automated via MCP servers (AWS, GitHub, Terraform, Datadog, PagerDuty, SonarQube, Snyk) and which are firmly human-only (compliance decisions, SLO definition, DR strategy, pen testing). Each server has a risk rating and safety rules. What it’s NOT It’s not perfect or holistic. It’s guardrails will help keep your code closer to being operable. It’s not a compliance certification. It references GDPR, PCI-DSS, etc. as examples but it doesn’t make your code compliant. And it’ll become outdated — each pillar file has a “last reviewed” date so staleness is visible. Tech opinions It leans Go, Python 3 with strict types, TypeScript strict mode, OpenTelemetry, structured JSON logging, and AWS serverless where the setup burden is high. These are my preferences — fork and change them. Repo https://github.com/leighstillard/claude.md-boilerplate Looking for feedback on: Gaps in the pillar files — failure modes I haven’t covered Rules that are too prescriptive for practical use Better approaches to the context window problem MCP server recommendations I’ve missed Unlicense, so do whatever you want with it. submitted by /u/YoghiThorn
Originally posted by u/YoghiThorn on r/ClaudeCode
