HomeClientsClaude Code
CLAUDE.md Specification1488 Tailored RulesTarget: CLAUDE.md

197 Industrial Architecture Guidelines for Claude Code (CLAUDE.md)

Production backend guidelines and anti-hallucination specifications engineered for Anthropic Claude Code CLI. Standardize Go Clean Architecture, Rust Tokio, Python FastAPI, PostgreSQL, Valkey, subagent boundaries, and multi-package monorepo invariants in CLAUDE.md.

Root Memory Anchoring

Persists guidelines across multi-turn terminal sessions without context loss.

Strict Build Verification

Enforces running real project build & test commands before concluding.

Safe Tool Execution

Restricts destructive git commands and maintains atomic change commits.

npx agentrules-cli export --client claude-code
View Config Spec
Domain Focus:Backend Services, Systems & CLI Invariants
Showing 24 of 1488 native tailored rules for Claude CodeTAILORED ALLOCATION
fastify-5-schema-compilers-encapsulation-production-standard
backendcritical

Fastify 5 Schema Compilers & Encapsulation Production Standard

Fastify relies on lexical encapsulation contexts to sandbox decorators, hooks, and compiled validation/serialization schemas without memory leaks or cross-tenant bleed. In Fastify 5, misuse of global compilers or failing to encapsulate plugin boundaries causes compiled `fast-json-stringify` serializers and Ajv validators to either crash on duplicate IDs, leak private data across sibling scopes, or bypass JIT compilation optimizations. Production services must enforce strict encapsulation hierarchies and type-safe schema compilation across every routing subtree.

Blocks:Mutating global AJV/fast-json-stringify compilers or exposing route-level decorators and hooks across sibling plugin contexts without encapsulation boundaries.
Targets:Cursor•Claude•Windsurf•Codex
bun-sqlite-wal-concurrency
backendcritical

Bun Embedded SQLite WAL Mode & Transaction Synchronization Standard

Production database standard for bun:sqlite. Mandates enabling Write-Ahead Logging (PRAGMA journal_mode = WAL), busy timeouts, and using db.transaction() for atomic operations without lock starvation.

Blocks:AI opens bun:sqlite with default rollback journals and un-isolated batch inserts, triggering SQLITE_BUSY crashes under concurrent requests.
Targets:Cursor•Claude•Windsurf•Codex
drizzle-orm-batch-transactions
backendcritical

Drizzle ORM Batch API & Interactive Transaction Isolation Standard

Production database standard for Drizzle ORM (PostgreSQL & MySQL). Mandates using db.batch() over HTTP drivers to prevent round-trip waterfalls, explicit db.transaction() with serializable/read-committed isolation, and strictly avoids unawaited query promises.

Blocks:AI loops single insert queries over serverless HTTP DB drivers (Neon / PlanetScale), creating 20x network latency waterfalls and partial failure states.
Targets:Cursor•Claude•Windsurf•Codex
temporal-io-deterministic-workflow
backendcritical

Temporal.io Workflow Code Determinism & Side Effect Isolation Standard

Production standard for Temporal.io distributed orchestrations. Mandates strict determinism inside workflow functions, strictly prohibiting Math.random(), Date.now(), mutable global variables, or direct network/database calls outside Temporal Activities.

Blocks:AI calls Date.now() or fetch() directly inside a Temporal workflow function, causing non-deterministic replay crashes during worker upgrades.
Targets:Cursor•Claude•Windsurf•Codex
valkey-8-0-threaded-io-cluster-failover-production-standard
backendcritical

Valkey 8.0 Threaded I/O & Cluster Failover Production Standard & Concurrency Guardrail

Valkey 8.0 introduces dual-channel multi-threaded I/O to scale network throughput while preserving single-threaded execution atomicity. Clustered deployments must strictly handle MOVED/ASK redirects and slot hashing constraints during node failovers and shard migration. Failure to enforce slot co-locality via hash tags in multi-key operations and Lua scripts causes CROSSSLOT errors and catastrophic transactional rollback failures during cluster rebalancing.

Blocks:Executing un-hashed multi-key commands and Lua scripts across disparate nodes while failing to handle cluster redirects and transient failover states.
Targets:Cursor•Claude•Windsurf•Codex
surrealdb-2-0-live-queries-record-links-production-standard
backendcritical

SurrealDB 2.0 Live Queries & Record Links Production Standard

SurrealDB 2.0 introduces strict RecordId types, an overhauled Rust engine, and push-based LIVE QUERY streaming over WebSockets. In production, unmanaged live queries cause persistent socket leaks and cluster memory exhaustion, while handling record links as arbitrary strings breaks transactional graph traversal and schema validation.

Blocks:Treating record IDs as raw interpolated strings and abandoning live query UUID subscriptions without deterministic teardown.
Targets:Cursor•Claude•Windsurf•Codex
duckdb-node-js-zero-copy-apache-arrow-ingest-production-standard
backendcritical

DuckDB Node.js Zero-Copy Apache Arrow Ingest & Concurrency Standard

DuckDB in Node.js requires strict adherence to zero-copy memory boundaries when streaming Arrow IPC records and executing parallel analytical queries across connection pools. Naive JSON serialization, raw ArrayBuffer copies, or concurrent queries sharing a single un-pooled Connection instance trigger V8 heap exhaustion, memory leaks, or native segfaults. Production architectures must enforce worker-safe connection pooling, explicit Arrow RecordBatch streaming via C++ IPC bindings, and strictly bounded memory limits.

Blocks:Deserializing analytical query results into native V8 JavaScript objects or executing concurrent queries on a single un-pooled DuckDB Connection handle.
Targets:Cursor•Claude•Windsurf•Codex
valkey-8-0-threaded-io-cluster-failover-guardrails
backendcritical

Valkey 8.0 Threaded I/O & Cluster Failover Production Standards

Valkey 8.0 leverages asynchronous multi-threaded I/O for socket read/write operations while preserving single-threaded execution for command mutations. In distributed cluster deployments, unhandled MOVED and ASK redirections during automatic master failovers cause cascading connection pool exhaustion and silent command drops. Furthermore, multi-key operations and Lua scripts execute atomically only when all involved keys map to the identical cluster hash slot via explicit hash tags.

Blocks:Executing cross-slot multi-key commands without hash tags while ignoring cluster failover redirects and socket pool saturation.
Targets:Cursor•Claude•Windsurf•Codex
langgraph-2026-stateful-checkpointers-human-in-the-loop-production-standard
backendcritical

LangGraph Stateful Checkpointers & Resilient Human-in-the-Loop Concurrency Guardrail

LangGraph production systems require durable checkpointers, deterministic thread scoping, and atomic human-in-the-loop (HITL) interrupt semantics to preserve workflow states across restarts and horizontal scaling. Relying on transient in-memory checkpointers or blocking asynchronous loops destroys state continuity and causes workflow deadlocks during deployments. Teams must mandate transactional state backends, native interrupt triggers, and schema-validated resumes within immutable channel reducers.

Blocks:Deploying ephemeral in-memory checkpointers in distributed environments and hijacking graph control with unpersisted manual prompts instead of native interrupt primitives.
Targets:Cursor•Claude•Windsurf•Codex
litellm-proxy-load-balancing-fallback-routing-production-standard
backendcritical

LiteLLM Proxy Load Balancing & Fallback Routing Production Standard

Production LiteLLM proxy deployments must maintain deterministic fallback topologies, bounded semantic cache lifecycles, and tenant-isolated token quota budgets across heterogeneous model providers. Without explicit circuit breaking and tier-aware load balancing, transient provider rate limits escalate into catastrophic cascading failures across upstream microservices. Reliable gateway architectures decouple client call-sites from provider-specific error formats by enforcing uniform retry budgets and distributed cache invalidation.

Blocks:Naive direct model invocations lacking circuit breakers, fallback groups, and budget bounds that crash downstream services on provider HTTP 429 bursts.
Targets:Cursor•Claude•Windsurf•Codex
valkey-threaded-io-cluster-failover-standard
backendcritical

Valkey 8.0 Multi-Threaded I/O, Cluster Slot Pinning, and Failover Resilience

Enforces deterministic cluster hash tagging for multi-key atomic operations and Lua scripts to prevent CROSSSLOT execution failures in Valkey 8.0. Mandates dynamic cluster topology discovery, backpressure-aware connection pooling for threaded I/O, and automated retry mechanisms for MOVED and ASK redirects during cluster failovers.

Blocks:Unpinned Multi-Key Script Execution with Naive Single-Node Clients Failing During Failover Re-Sharding
Targets:Cursor•Claude•Windsurf•Codex
bun-sqlite-wal-s3-native-storage-standard
backendcritical

Bun 1.2 SQLite WAL Concurrency & Native S3 Streaming Invariant

Enforces strict concurrency and zero-copy data flow standards for Bun 1.2 applications using native bun:sqlite and Bun.s3. Forbids executing asynchronous network I/O or S3 streaming within synchronous SQLite WAL transaction boundaries, mandates optimal WAL pragmas, and enforces end-to-end memory-efficient streaming.

Blocks:Interleaving Async S3 Network I/O Inside SQLite Write Transactions Causing Database Lock Starvation
Targets:Cursor•Claude•Windsurf•Codex
axum-08-state-tower-resilience
backendcritical

Axum 0.8 Type-Safe State Extractors & Tower Service Composition

Enforces strict type safety and architectural invariants for Axum 0.8 applications using Router::with_state, sub-state derivation via FromRef, and Tower middleware composition. Prohibits untyped Extension state sharing and unhandled extractor rejections that trigger server panics or unformatted 500 responses.

Blocks:Untyped Extension Injection and Unhandled Missing State Panics in Axum 0.8
Targets:Cursor•Claude•Windsurf•Codex
valkey-8-threaded-io-cluster-failover-standard
backendcritical

Valkey 8.0 Threaded I/O, Cluster Routing, and Script Atomicity Guardrails

Enforces strict cluster-topology handling, deterministic hash-tag slot affinity for transactional scripts, and resilient backoff redirection protocols for Valkey 8.0 multi-threaded deployments. Prevents CROSSSLOT evaluation exceptions, slot discovery thundering herds during failovers, and socket contention during threaded I/O execution.

Blocks:Un-tagged multi-key Lua scripting and unhandled MOVED/ASK redirect storms during node failover.
Targets:Cursor•Claude•Windsurf•Codex
bun-sqlite-wal-s3-streaming-invariants
backendcritical

Bun 1.2 Native SQLite WAL Concurrency & S3 Direct-Stream Pipeline Invariants

Enforces strict production invariants for Bun 1.2 embedded database and object storage operations. Mandates WAL-mode PRAGMA concurrency configuration, prepared statement lifecycle reuse in 'bun:sqlite', and zero-copy S3 streaming via 'Bun.s3' to prevent node heap buffer exhaustion.

Blocks:Buffering multi-megabyte payloads in process heap while executing un-indexed SQLite writes in rollback journal mode without statement preparation.
Targets:Cursor•Claude•Windsurf•Codex
go-chi-v5-middleware-graceful-shutdown
backendcritical

Go Chi v5 Deterministic Middleware Hierarchy & Signal-Driven Graceful Shutdown

Enforces strict middleware sequencing, hierarchical sub-router boundary isolation, context-propagated timeout cancellation, and zero-downtime signal-driven HTTP server shutdown in Go Chi v5 services. Eliminates dropped in-flight requests during rolling deployments, unmanaged goroutine leaks, and middleware duplication across mounted subtrees.

Blocks:Uncontrolled Process Termination, Inverted Middleware Stacks, and Context-Blind Handler Execution
Targets:Cursor•Claude•Windsurf•Codex
valkey-8-cluster-threaded-io-failover-standard
backendcritical

Valkey 8.0 Multi-Threaded I/O, Cluster Slot Redirects, and Hash-Tag Script Atomicity

Enforces strict hash-tag slot pinning for atomic multi-key Lua/Functions and resilient MOVED/ASK cluster redirection handling in Valkey 8.0. Prevents CROSSSLOT runtime exceptions, connection thrashing during automated failovers, and false concurrency assumptions under multi-threaded I/O.

Blocks:Executing unpinned multi-key Lua scripts across cluster slots while mishandling MOVED/ASK redirects and failover state transitions.
Targets:Cursor•Claude•Windsurf•Codex
bun-sqlite-wal-s3-native-storage
backendcritical

Bun 1.2 Embedded SQLite WAL & S3 Native Zero-Copy Streaming Invariants

Enforces deterministic concurrency control and high-throughput zero-copy streaming when combining Bun 1.2's native bun:sqlite engine with Bun.s3 storage. Mandates WAL journal mode with synchronous normal settings, prepared statement reuse, and direct stream piping between SQLite BLOB reads/writes and native S3 multipart operations without intermediate in-memory buffering. Eliminates event loop blocking, file lock deadlocks, and Node.js wrapper overhead.

Blocks:Unbuffered in-memory reads, missing WAL journal configuration, and redundant AWS-SDK wrapping in Bun runtimes
Targets:Cursor•Claude•Windsurf•Codex
axum-08-state-tower-resilience-standard
backendcritical

Axum 0.8 Type-Safe State Composition and Tower Service Invariants

Enforces strict type safety and panic resilience across Axum 0.8 State extractors and Tower middleware stacks. Mandates compile-time substate extraction via FromRef, prevents router state decoupling panics, and guarantees zero unhandled rejection panics through CatchPanic layers and custom IntoResponse error boundaries.

Blocks:Runtime router panics and broken substate isolation caused by untyped state degradation, missing CatchPanic middleware, and unconstrained Tower layers.
Targets:Cursor•Claude•Windsurf•Codex
valkey-8-cluster-slot-routing-atomicity
backendcritical

Valkey 8.0 Cluster Hash Tagging, Redirection Handling, and Non-Blocking Scripting

Valkey 8.0 multi-threaded I/O parallelizes socket read/write processing across I/O threads but maintains single-threaded execution semantics for data mutability and cluster slot routing across nodes (slots 0-16383). Developers must enforce explicit hash tagging for multi-key atomicity, strictly declare all keys in Lua or Function execution to prevent cross-slot deadlocks, and implement resilient MOVED and ASK redirection handlers with slot cache invalidation during cluster failover.

Blocks:Cross-Slot Lua Execution and Unhandled Failover Redirections Inducing Stalled I/O Pipelines
Targets:Cursor•Claude•Windsurf•Codex
valkey-8-threaded-io-cluster-failover
backendcritical

Valkey 8.0 Threaded I/O Configuration, Cluster Failover, and Lua Slot Invariants

Enforces strict cluster routing, hash-tag slot alignment, and resilient connection pooling under Valkey 8.0 multi-threaded I/O architectures. Guarantees atomic Lua script execution across cluster shards while preventing unhandled MOVED/ASK redirect storms and failover split-brain writes.

Blocks:Executing untagged multi-key operations and unhandled MOVED/ASK redirects across Valkey cluster shards.
Targets:Cursor•Claude•Windsurf•Codex
bun-sqlite-wal-s3-native-standard
backendcritical

Bun 1.2 Embedded SQLite WAL & S3 Native Zero-Copy Streaming Invariants

Enforces high-throughput architectural patterns using Bun 1.2 native bun:sqlite and Bun.s3. Mandates strict WAL mode configuration with synchronous NORMAL pragmas, zero-copy buffer queries, and streaming multipart uploads directly via Bun.s3 client to prevent event loop starvation and heap bloat.

Blocks:Blocking disk I/O via default DELETE journal mode and buffering S3 payloads entirely in RAM
Targets:Cursor•Claude•Windsurf•Codex
valkey-8-cluster-slot-atomicity-failover
backendcritical

Valkey 8.0 Cluster Hash Tagging, Redirection & Failover Invariants

Valkey 8.0 leverages multi-threaded I/O for socket processing while enforcing single-threaded command determinism across 16,384 cluster slots. Distributed systems targeting Valkey Cluster MUST enforce hash tagging for multi-key operations and Lua scripts to prevent CROSSSLOT errors, and MUST handle MOVED/ASK redirections with managed topology refreshes during master failover.

Blocks:Un-tagged Multi-Key Operations and Unbounded Redirection Failures During Cluster Failover
Targets:Cursor•Claude•Windsurf•Codex
axum-0-8-state-tower-guardrails
backendcritical

Axum 0.8 Type-Safe State Extractors & Tower Middleware Invariants

Enforces Axum 0.8 compile-time type-safe state access via FromRef sub-states rather than fallible dynamic Extension extractors. Mandates defensive Tower middleware ordering with CatchPanicLayer and structured custom rejection handlers to ensure zero unhandled panics or degraded error telemetry.

Blocks:Dynamic Extension Extraction and Unprotected Tower Pipelines Yielding Runtime Panics
Targets:Cursor•Claude•Windsurf•Codex

Claude Code Native Configuration Format

Target location: ./CLAUDE.md

# File: CLAUDE.md
# AgentRules: Industrial Architecture Guidelines for Claude Code
 
 ## Verification Commands
 - Build: `npm run build` or `pnpm build`
 - Test: `npm test -- --run` or `pytest tests/ -v`
 - AST Gate: `node scripts/pipeline/validate_and_compile.js`
 
 ## Core Engineering Invariants
 1. Read existing repository patterns before proposing new abstractions.
 2. Never revert uncommitted user modifications or wipe unrelated git state.
 3. Always run automated verification commands before concluding any task turn.
 4. Keep code changes tightly scoped to the specific user issue.

Top AI Hallucination Traps Solved for Claude Code

Without deterministic negative constraints, AI coding models frequently fall into common architectural failure modes:

1Runaway agent tool execution loops modifying code without running verification builds
2Hallucinating outdated package API signatures when interacting with external SDKs
3Polluting git history by mixing bulk style rewrites with critical functional bug fixes
4Event loop blocking in asynchronous Python/Go servers from un-awaited I/O calls
5Accidental deletion of unstaged user changes during shell git reset operations

Frequently Asked Questions: Claude Code CLI (CLAUDE.md)

Common questions about configuring rules, optimizing context token usage, and enforcing architectural invariants in Claude Code.

Targeted Architecture Patterns & Long-Tail Scopes for Claude Code

how to structure CLAUDE.md for fullstack monoreposclaude code 3.7 sonnet thinking mode architecture instructionsclaude code terminal tool execution safety guardrailsprevent destructive git commands in claude code agent runsclaude code test driven development verification loopsclaude code vs cursor rules conversion toolclaude code python uv fast package manager directivesclaude code docker compose service isolation invariantsclaude code microservices boundary enforcement guidelinesenterprise claude.md compliance standards and ast check