Skip to content

feat: add layered AI rules system (.claude/rules/)#20

Merged
buddingengineers12345 merged 2 commits intomainfrom
cursor/project-template-rules-setup-8f9b
Apr 6, 2026
Merged

feat: add layered AI rules system (.claude/rules/)#20
buddingengineers12345 merged 2 commits intomainfrom
cursor/project-template-rules-setup-8f9b

Conversation

@buddingengineers12345
Copy link
Copy Markdown
Owner

Summary

Adds a layered plain-Markdown rules system under .claude/rules/ (template maintainer context) and template/.claude/rules/ (generated project context). Rules are tool-agnostic — they work with Claude Code, Cursor, or any LLM that can read context from a directory.

What was added

Root .claude/rules/ (template maintainer)

.claude/rules/
├── README.md              ← structure overview + how to write new rules
├── common/                ← language-agnostic principles
│   ├── coding-style.md
│   ├── git-workflow.md
│   ├── testing.md
│   ├── security.md
│   ├── development-workflow.md
│   └── code-review.md
├── python/                ← Python-specific (extends common/)
│   ├── coding-style.md
│   ├── testing.md
│   ├── patterns.md
│   ├── security.md
│   └── hooks.md
├── jinja/                 ← Jinja2 templates
│   ├── coding-style.md
│   └── testing.md
├── bash/                  ← shell hook scripts
│   ├── coding-style.md
│   └── security.md
├── markdown/
│   └── conventions.md
├── yaml/
│   └── conventions.md
└── copier/                ← Copier template conventions (this repo only)
    └── template-conventions.md

template/.claude/rules/ (generated projects)

Subset covering common, python, bash, and markdown — no Jinja or Copier rules (generated projects do not use those):

  • common/: coding-style, git-workflow, testing, security, development-workflow, code-review
  • python/: coding-style (Jinja — references {{ package_name }}), testing, patterns (Jinja), security, hooks
  • bash/: coding-style, security
  • markdown/: conventions

Two Python files use the .jinja suffix because they reference {{ package_name }} from Copier variables.

CLAUDE.md and template/CLAUDE.md.jinja

Added an "AI rules" section pointing to the rules directory and describing the dual-hierarchy.

Design decisions

  • Plain Markdown, no tool-specific syntax: no .mdc frontmatter, no Cursor-specific fields. Any tool that can read a file benefits from them.
  • Layered common → language-specific: matches the pattern from the reference repo. Language-specific rules override common rules where they conflict.
  • Dual hierarchy preserved: root rules for template maintainers; template rules for generated projects. Copier/Jinja/YAML rules stay in the root only.
  • # applies-to: comments: optional YAML-comment annotations at the top of language-specific files indicate which glob patterns apply; tools that understand frontmatter can use them, others ignore them.
  • README.md explains how to add new rules: covers directory choice, naming, the extending-common pattern, and the dual-hierarchy mirror requirement.
Open in Web Open in Cursor 

cursoragent and others added 2 commits April 6, 2026 10:56
…ude/rules/

Adds a plain-Markdown rules system that works with any AI assistant
(Claude Code, Cursor, or any LLM) — no tool-specific frontmatter.

Root .claude/rules/ (template maintainer context):
  common/   coding-style, git-workflow, testing, security,
            development-workflow, code-review
  python/   coding-style, testing, patterns, security, hooks
  jinja/    coding-style, testing (Copier template files)
  bash/     coding-style, security (hook scripts)
  markdown/ file-placement rules, authoring conventions
  yaml/     copier.yml and GitHub Actions conventions
  copier/   template-conventions (dual-hierarchy, versioning)

template/.claude/rules/ (generated project context):
  common/   coding-style, git-workflow, testing, security,
            development-workflow, code-review
  python/   coding-style (Jinja), testing, patterns (Jinja),
            security, hooks
  bash/     coding-style, security
  markdown/ conventions

Also includes .claude/rules/README.md explaining the structure,
priority rules, and how to write new rules in the future.

CLAUDE.md and template/CLAUDE.md.jinja updated to reference
the new rules directory.

Co-authored-by: buddingengineers12345 <buddingengineers12345@gmail.com>
…te-rules-setup-8f9b

Co-authored-by: buddingengineers12345 <buddingengineers12345@gmail.com>
@buddingengineers12345 buddingengineers12345 marked this pull request as ready for review April 6, 2026 11:00
@buddingengineers12345 buddingengineers12345 merged commit 890e3d0 into main Apr 6, 2026
7 of 9 checks passed
@buddingengineers12345 buddingengineers12345 deleted the cursor/project-template-rules-setup-8f9b branch April 6, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants