Sandbox
@lifedever/claude-rules

Project rules for Claude Code, Cursor, and Copilot

Claude Rules is a template library for AI coding instructions. You pick the base, language, and framework files your project needs, then generate a rules file that your agent can follow.

189 stars7 forksUpdated 6mo ago
Who it's for

Builders who want their coding assistant to follow the same project standards across new and existing codebases.

What it delivers

You can generate a project rules file that keeps agent-written code more consistent and closer to your standards.

What it does

Three-layer rules system

Combines `base`, `languages`, and `frameworks` files, with framework rules overriding language rules and language rules overriding base rules.

Claude Code plugin flow

Supports `/init-rules` in Claude Code after installing the marketplace plugin.

Manual rules assembly

Lets you concatenate the Markdown files you need into `CLAUDE.md` or another instructions file.

Tool-specific output targets

Maps the same rules content to Claude Code, Cursor, Antigravity, and GitHub Copilot instruction files.

Concrete rule style

Uses actionable directives, bad/good examples, and limits like function length and nesting depth.

How to get it

  1. 1Run
    # Step 1: Add the marketplace
    claude plugin marketplace add lifedever/claude-rules
    
    # Step 2: Install the plugin
    claude plugin install init-claude-rules@claude-rules
    
    # Step 3: Restart Claude Code
  2. 2Open any project in Claude Code and run
    /init-rules
  3. 3When new rules are added upstream, update the local cache
    claude plugin marketplace update claude-rules
  4. 4Run
    claude plugin uninstall init-claude-rules@claude-rules
    claude plugin marketplace remove claude-rules
  5. 5Clone this repo and concatenate the rule files you need
    git clone https://github.com/lifedever/claude-rules.git
    cd claude-rules
    
    # Example: Vue 3 + TypeScript project
    cat base/core.md base/git.md languages/typescript.md frameworks/vue.md > /path/to/project/CLAUDE.md

README

Claude Rules

License: MIT GitHub stars PRs Welcome Website

English | 中文

Coding standards template library for AI coding assistants. Combine base + language + framework layers to generate a project-specific rules file that keeps AI-generated code clean and consistent.

The Problem

AI coding assistants tend to mimic existing code style in legacy projects — including bad habits. The core principle of this library:

Don't imitate legacy code. Refactor according to the standards.

Every rule is a concrete, actionable directive (not vague "use proper XX"), with "Bad / Good" code comparison examples.

Directory Structure

claude-rules/
├── base/                   # Universal (required)
│   ├── core.md             # Core principles: legacy code attitude, quality metrics, naming, architecture
│   └── git.md              # Git commit message conventions
│
├── languages/              # Pick by language
│   ├── typescript.md       # No any/enum/barrel exports, as const, import type
│   ├── javascript.md       # ES2022+, JSDoc type annotations, ESM only
│   ├── java.md             # Java 17+ record/sealed/pattern matching, Optional
│   ├── kotlin.md           # Null safety, structured concurrency, sealed class
│   ├── swift.md            # guard let, async/await, actor, Protocol
│   ├── python.md           # ruff, type annotations, Protocol, uv/poetry
│   ├── html.md             # Semantic tags, accessibility, no div soup
│   ├── css.md              # Custom properties, Flexbox/Grid, BEM, modern features
│   ├── go.md               # Error wrapping, small interfaces, structured concurrency
│   └── rust.md             # Ownership/borrowing, thiserror/anyhow, iterators, Clippy
│
└── frameworks/             # Pick by framework
    ├── vue.md              # script setup, ref vs reactive, composable patterns
    ├── react.md            # Hooks rules, correct useEffect, state layering
    ├── swiftui.md          # @Observable (not legacy ObservableObject), SwiftData
    ├── springboot.md       # Layered architecture, DTO, global exception handling
    └── tauri.md            # Command design, service encapsulation, security config

Three-Layer Architecture

┌─────────────────────────────────────────────┐
│              base (required)                 │  core.md + git.md
│  Legacy code attitude / Quality metrics /   │  Applies to all projects
│  Naming / Architecture                      │
├─────────────────────────────────────────────┤
│            language (pick)                   │  typescript.md / java.md / ...
│  Type system / Naming conventions /         │  Based on project language
│  Language-specific features                 │
├─────────────────────────────────────────────┤
│            framework (pick)                  │  vue.md / react.md / ...
│  Component standards / State management /   │  Based on project framework
│  Architecture patterns                      │
└─────────────────────────────────────────────┘

Rule priority: framework > language > base (specific rules override general rules)

Usage

Claude Code Plugin (Recommended)

Install

# Step 1: Add the marketplace
claude plugin marketplace add lifedever/claude-rules

# Step 2: Install the plugin
claude plugin install init-claude-rules@claude-rules

# Step 3: Restart Claude Code

Use

Open any project in Claude Code and run:

/init-rules

The plugin will:

  1. Auto-detect your project's tech stack (TypeScript, Vue, React, etc.)
  2. Ask you to confirm the detected stack
  3. Read the matching rule files from the plugin
  4. Generate CLAUDE.md in your project root

Update

When new rules are added upstream, update the local cache:

claude plugin marketplace update claude-rules

Then restart Claude Code. To apply updated rules to a project that already has CLAUDE.md, run /init-rules again — the plugin will ask before overwriting.

Uninstall

claude plugin uninstall init-claude-rules@claude-rules
claude plugin marketplace remove claude-rules

Manual Usage

Clone this repo and concatenate the rule files you need:

git clone https://github.com/lifedever/claude-rules.git
cd claude-rules

# Example: Vue 3 + TypeScript project
cat base/core.md base/git.md languages/typescript.md frameworks/vue.md > /path/to/project/CLAUDE.md

The rules are plain Markdown and work with any AI coding tool. Just place the output where your tool expects:

ToolTarget File
Claude CodeCLAUDE.md
Cursor.cursorrules or .cursor/rules/*.mdc
Antigravity.antigravity/rules.md
GitHub Copilot.github/copilot-instructions.md

Design Principles

  1. Actionable — Every rule is directly executable by AI, no vague wording
  2. Exemplified — Key rules include "Bad" and "Good" code comparisons
  3. Quantified — Functions ≤30 lines, files ≤300 lines, nesting ≤3 levels, parameters ≤4
  4. Up-to-date — Uses modern APIs for each language/framework (@Observable, record, as const, etc.)
  5. Not hollow — Instead of "handle errors properly", specifies exactly how to handle them

Contributing

PRs for new languages or frameworks are welcome. Please follow these guidelines:

  • Rules must be concrete and actionable — no "use appropriate/proper" phrasing
  • Key rules should include code examples (bad practice + good practice)
  • Recommend modern idioms — don't document outdated APIs
  • Write in English

References

License

MIT

Files in the repo

Repository payload10 top-level entries
  • .claude
  • .claude-plugin
  • .github
  • base
  • docs
  • frameworks
  • languages
  • LICENSE
  • README_CN.md
  • README.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More rules & prompts

All parts of Claude Code's system prompt, 27 builtin tool descriptions, sub agent prompts (Plan/Explore/Task), utility prompts (CLAUDE.md, compact, statusline, magic docs, WebFetch, Bash cmd, security review, agent creation). Updated for each Claude Code version.

13k
wanshuiyin/
HERO-Anti-OverDefense

HERO = Hashing · Edge cases · Rubrics · Overbuild — the four shapes coding agents over-defend in. A paste-in contract that stops them. Works with Claude Code, Codex, Antigravity, Cursor, Copilot, Windsurf, Gemini CLI.

444
ilindaniel/
ponytail-lite

Stop agents from over-engineering. Inspired by Ponytail, but without the plugin madness. Just one AGENTS.md file.

171
repowise-dev/
claude-code-prompts

Independently authored prompt templates for AI coding agents — system prompts, tool prompts, agent delegation, memory management, and multi-agent coordination. Informed by studying Claude Code.

1.2k