vibe-coding-rules
54 production architecture rules for vibe coding with Claude Code & Cursor. Drop-in CLAUDE.md, .cursor/rules, and .claude/skills for FastAPI, Next.js 15, and Go 1.22+ — turn AI-assisted coding from prototype hack to production.
Install / Use
npx skills add yerdaulet-damir/vibe-coding-rulesInstalls into whichever agent you are using.
.cursorrules
Cursor IDE rules (legacy)
Quality Score
Category
AI & Machine LearningSupported Platforms
Skill content
View source on GitHubvibecodex — vibe coding rules for production
54 production architecture principles your AI coding agent (Claude Code, Cursor) follows automatically. Drop-in
CLAUDE.md,.cursor/rules/, and.claude/skills/for FastAPI, Next.js 15, and Go 1.22+. MIT.
npx @aimyerdaulet/vibecodex init
📘 Principles · 🐍 FastAPI example · ⚡ Next.js example · 🐹 Go example · 🤖 Claude skills · 🌐 vibecodex.dev
What is vibecodex?
vibecodex is the clean-code bible for vibe coding — 54 numbered architecture principles (A1–F10) that turn AI coding agents from fast juniors into disciplined seniors. You drop one CLAUDE.md plus a folder of Cursor rules into your repo, and from the next prompt every Claude Code or Cursor session follows production patterns: file size limits, anti-corruption layers, idempotency keys, bulkhead isolation, single-writer invariants, hexagonal boundaries.
It's built for vibe coders, solo devs, and indie hackers who ship fast with AI but don't want their Friday-night SaaS to become an unmaintainable 1,400-line router by Sunday.
Three stacks. One ruleset. Zero dependencies on a specific agent.
<details> <summary><b>📖 Table of Contents</b></summary>
- 🚀 Quick Start
- 🚨 The problem
- 🛠️ 54 Production Principles
- 📂 Directory Structure
- 🚀 Reference Implementations
- 🤖 Claude Code Skills
- 🛠️ Copy-Paste AI Config
- 📊 vs Other Templates
- ❓ FAQ
- 🎯 When to use this blueprint
- 🤝 Contributing
- 📜 Citations
🚀 Quick Start
# Add vibecodex rules to your project (any stack)
git clone https://github.com/yerdaulet-damir/vibe-coding-rules.git /tmp/vibecodex
# 1. Drop CLAUDE.md into your repo root — Claude reads it on every session
cp /tmp/vibecodex/CLAUDE.md ./
# 2. Copy Cursor rules
cp -r /tmp/vibecodex/.cursor/rules/ .cursor/rules/
# 3. Copy Claude Code skills (debug-backend, new-feature, split-monolith, etc.)
cp -r /tmp/vibecodex/.claude/skills/ .claude/skills/
That's it. Your AI agent now follows 54 production principles from line one.
For new projects, start from one of the reference apps:
| Stack | Command | What you get |
|-------|---------|--------------|
| FastAPI | cp -r /tmp/vibecodex/reference/app/ ./backend/app/ | Hexagonal Python with credits, providers, async jobs |
| Next.js 15 | cp -r /tmp/vibecodex/examples/nextjs/ ./frontend/ | RSC + typed cache-tag DSL + Drizzle + Better Auth |
| Go 1.22+ | cp -r /tmp/vibecodex/examples/go/ ./service/ | cmd/+internal/ + bulkhead clients + graceful shutdown |
🚨 The problem
You start a project on Friday. By Sunday you have 14 endpoints, a working LLM integration, OAuth, Stripe, and a deploy pipeline. The AI is moving fast. So are you. Everything works.
Six weeks later, routers/generate.py is 1400 lines, services/ai_router.py ships a dict from OpenAI directly into your billing logic, the SQLAlchemy Session reaches into every layer including the JWT decoder, and a single hung httpx call to one provider exhausts your file descriptors and takes down image, video, and audio at once. The AI is still moving fast — but now every change touches eight files, breaks two of them, and your test suite mocks Session 47 different ways.
This isn't an AI failure. AI assistants produce structurally correct, locally optimal code. What they don't enforce — and what no template enforces by default — is architectural consistency at scale: layer boundaries, file size, ports & adapters, single-writer invariants, bulkhead isolation, typed cache-tag DSLs, hexagonal domain boundaries, idempotency keys, graceful shutdown rituals.
This repo codifies all of it into 54 rules that fit on a few pages, ship as CLAUDE.md + .cursor/rules/ + .claude/skills/, and turn your AI partner from a fast junior into a disciplined senior — across FastAPI, Next.js 15, and Go 1.22+.
🛠️ 54 Production Principles
The vibecodex blueprint covers 6 parts spanning Python, TypeScript, and Go — each one solving a recurring failure mode of vibe-coded apps:
| # | Stack | Part | Focus | Principles |
|---|-------|------|-------|-----------|
| A | 🐍 FastAPI | Decomposition | folder/file boundaries, single-writer | 8 |
| B | 🐍 FastAPI | Integration | hexagonal, ACL, bulkhead, idempotency, observability | 10 |
| C | ⚡ Next.js | Decomposition | feature-driven colocation, RSC defaults | 10 |
| D | ⚡ Next.js | Modern (2024-25) | typed cache-tag DSL, use(), PPR, Better Auth, Drizzle | 6 |
| E | 🐹 Go | Decomposition | internal/, consumer-side interfaces, no utils | 8 |
| F | 🐹 Go | Integration | context.Context first, errgroup, bulkhead, graceful shutdown | 10 |
| Σ | | | | 54 |
🧩 Part A — Safe Decomposition (8 principles)
How to split files and folders without breaking imports and without losing the thread of the codebase.
-
Folder-instead-of-file when domain splits by type. If
<details><summary>before / after</summary>routers/generate.pyis starting to handleimage,video,audio, convert it to a packagerouters/generate/{image.py,video.py,audio.py,__init__.py}and re-export the combined router.main.pydoesn't change.# BEFORE — routers/generate.py (820 lines, three domains tangled) @router.post("/image") async def generate_image(...): ... @router.post("/video") async def generate_video(...): ... @router.post("/audio") async def generate_audio(...): ...# AFTER — routers/generate/__init__.py from fastapi import APIRouter from .image import router as image_router from .video import router as video_router from .audio import router as audio_router router = APIRouter(prefix="/generate", tags=["generate"]) router.include_router(image_router) router.include_router(video_router) router.include_router(audio_router)
</details>main.pykeepsfrom app.routers.generate import router— zero caller changes. -
Static data ≠ runtime logic. Pricing tables, model registries, prompt templates go into
<details><summary>before / after</summary>data/(or<domain>/registry.py), never inline in a service file. Updating a price = a one-line PR, not a refactor.# BEFORE — services/ai_service.py PRICING = {"gpt-4o": 0.005, "claude-3-5": 0.003, ...} # 80 lines of constants class AIService: ...
</details># AFTER — data/model_pricing.py from decimal import Decimal PRICING: dict[str, Decimal] = { "gpt-4o": Decimal("0.005"), "claude-3-5": Decimal("0.003"), } # services/ai_service.py from app.data.model_pricing import PRICING -
Auth and schemas don't live with endpoints. A bloated
<details><summary>before / after</summary>routers/admin.pybecomesrouters/admin/{wallet,users}.pywith auth incore/admin_auth.pyand Pydantic schemas inschemas/admin/. Each file has one reason to change.# BEFORE — routers/admin.py (520 lines) def require_admin(user_id: str = Depends(get_current_user_id)): ... class AdjustWalletRequest(BaseModel): ... class ListUsersResponse(BaseModel): ... @router.post("/admin/wallet/adjust"): ... @router.get("/admin/users"): ...
</details># AFTER core/admin_auth.py # require_admin dep schemas/admin/wallet.py # AdjustWalletRequest schemas/admin/users.py # ListUsersResponse routers/admin/wallet.py # only HTTP for wallet ops routers/admin/users.py # only HTTP for user ops routers/admin/__init__.py # combines and re-exports -
Provider with N format APIs → file per format. A single Fal.ai client that does both image and video generation becomes
<details><summary>before / after</summary>providers/falai/{image.py,video.py,_client.py}. The HTTP plumbing (auth, retries, base URL) sits in_client.py; each format file owns its request/response shape.# BEFORE — providers/falai.py (640 lines, image+video request models tangled) class FalAiAdapter: async def generate_image(self, ...): ... async def generate_video(self, ...): ...
</details># AFTER — providers/falai/_client.py class FalClient: def __init__(self, *, api_key: str, http: httpx.AsyncClient): ... async def request(self, path: str, payload: dict) -> dict: ... # providers/falai/image.py from ._client import FalClient class FalImageAdapter: def __init__(self, client: FalClient): self._c = client async def generate(self, req: ImageRequest) -> GenerateResult | ProviderError: ... -
Worker-handlers do NOT live in the router.
routers/tasks.pystays HTTP-only (enqueue, list, cancel). Background processing goes toservices/task_handlers/{image,video,audio}.py. The router becomes a thin entry point you can read in 30 seconds. -
User-API ≠ Admin-API in the same service file.
wallet_service.py(500 lines) becomesservices/wallet/{user.py,admin.py,history.py,debt.py}with a sharedservices/wallet/_repo.py. User code can't accidentally import admin-only methods. -
Soft cap 400 LOC, hard cap 600 LOC per file. At 400 lines you plan the split. At 600 lines you split now — no exceptions. Enforced by
scripts/check_loc.pyin CI. -
Refactor without breaking changes.
<details><summary>example</summary>__init__.pyre-exports the old public names, so callers (and your AI assistant's stale memory of the codebase) don't break. Decomposition is invisible from the outside.
</details># services/wallet/__init__.py from .user import WalletUserService from .admin import WalletAdminService # Backwards-compat: old code did `from app.services.wallet_service import WalletService` WalletService = WalletUserService # alias keeps imports working during migration __all__ = ["WalletUserService", "WalletAdminService", "WalletService"]
🔌 Part
Truncated for display — read the full file on GitHub.
Related Skills
caveman
107.1k🪨 why use many token when few token do trick. Viral skill + proxy for coding agents that cuts 65% of tokens by talking like a caveman.
claude-mem
94.4kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Agent-Reach
84.2kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
Understand-Anything
83.5kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
