001-code-style — Claude Code rule: code style and setup
The 001-code-style rule sets conventions for naming, formatting, and readable code. Use it to give an agent consistent project-level guidance.
MIT ★ 97 updated 2026-06-11
.cursor/rules/001-code-style.mdcWhat 001-code-style does
The rule covers names for files, components, functions, variables, constants, and types. It calls for PascalCase on components and types, camelCase on functions and variables, and UPPER_SNAKE_CASE on constants. Boolean names should use prefixes such as is or has; function names should start with a verb.
Several formatting choices are placeholders: {{FILE_NAMING}}, {{INDENTATION}}, {{LINE_LENGTH}}, {{QUOTE_STYLE}}, and {{SEMICOLONS}}. Fill them in for your project. The rule has alwaysApply: true, so its guidance applies continuously once added.
It also asks for explicit return types, favors composition over inheritance, and rejects any in favor of unknown with type guards. To use it with Claude Code, save the rule at .claude/rules/001-code-style.md. Until the placeholders are set, those formatting requirements remain open-ended.
What it helps with
- standardize names for files and code entities
- set shared formatting conventions across a project
- replace
anywith checkedunknownvalues - keep business logic out of UI components
Example prompts for the agent
- Apply the project’s naming and formatting conventions to this code.
- Review this component and move its business logic out of the UI.
- Replace
anywithunknownand add appropriate type guards.
How to install 001-code-style
Manually: put the files in place
.cursor/rules/001-code-style.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/001-code-style.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/001-code-style.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/001-code-style.mdManually: put the files in place
.clinerules/001-code-style.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about 001-code-style
How do I install 001-code-style in Claude Code?
Add the rule file to your project at .claude/rules/001-code-style.md.
What does 001-code-style do?
It gives the agent naming and formatting conventions, along with guidance for types and code structure. The rule applies continuously.
Which settings should I configure first?
Set values for {{FILE_NAMING}}, {{INDENTATION}}, {{LINE_LENGTH}}, {{QUOTE_STYLE}}, and {{SEMICOLONS}} to match your project.
Source text
001-code-style.mdc · MIT
---
description: Code style, naming conventions, and formatting standards
globs:
alwaysApply: true
---
# Code Style & Conventions
## Naming Conventions
- Files: {{FILE_NAMING}} (e.g., kebab-case.tsx, snake_case.py)
- Components: PascalCase
- Functions: camelCase with verb prefixes (getUserData, calculateTotal)
- Variables: camelCase with auxiliary verbs for booleans (isLoading, hasError)
- Constants: UPPER_SNAKE_CASE
- Types/Interfaces: PascalCase
## Formatting
- Indentation: {{INDENTATION}} (e.g., 2 spaces)
- Line Length: {{LINE_LENGTH}} max (e.g., 100 chars)
- Quotes: {{QUOTE_STYLE}} (e.g., single quotes)
- Semicolons: {{SEMICOLONS}} (e.g., required)
- Trailing Commas: always in multi-line structures
## Readability
Code must be immediately understandable. Use descriptive naming. Maintain clear structure. Readable code over clever code.
## Do's
- Use explicit return types for functions
- Prefer composition over inheritance
- Use const assertions for literal types
- Implement proper error boundaries
## Don'ts
- No `any` types — use `unknown` with type guards
- No unhandled promise rejections
- No inline styles (use CSS framework)
- No business logic in UI components
© obviousworks · MIT · obviousworks/vibe-coding-ai-rules