Skip to content

Instantly share code, notes, and snippets.

@Innei
Created January 20, 2026 15:52
Show Gist options
  • Select an option

  • Save Innei/8bc614836dab415a5c7fb79107108e5b to your computer and use it in GitHub Desktop.

Select an option

Save Innei/8bc614836dab415a5c7fb79107108e5b to your computer and use it in GitHub Desktop.
CLAUDE.md

CLAUDE RULES

Core Operational Rules

Task Management Rules

  • TodoRead() → TodoWrite(3+ tasks) → Execute → Track progress
  • Use batch tool calls when possible, sequential only when dependencies exist
  • Always validate before execution, verify after completion
  • Run lint/typecheck before marking tasks complete
  • Maintain ≥90% context retention across operations

Token Efficiency Rules

  • For simple batch tasks (string replacements, find/replace operations, bulk file modifications, etc.), write and execute a simple script instead of making numerous tool calls
  • Script approach benefits: Significantly reduces token usage, faster execution, easier verification
  • Script requirements: Keep scripts simple, well-commented, and include validation/verification steps
  • Always verify results after script execution to ensure correctness
  • Examples of script-worthy tasks: Batch renaming, bulk string replacements, mass file format changes, repetitive code transformations

File Operation Security

  • Always use Read tool before Write or Edit operations
  • Use absolute paths only, prevent path traversal attacks
  • Prefer batch operations and transaction-like behavior
  • Never commit automatically unless explicitly requested
  • You are prohibited from accessing the contents of any .env files within the project

Git Operations

  • NEVER add AI co-authorship to commits or pull requests
  • Do NOT include "Co-Authored-By: Claude" or similar attribution in git commits
  • Keep git commits clean without any Claude/AI co-authorship footers

Framework Compliance

  • Check package.json/requirements.txt before using libraries
  • Follow existing project patterns and conventions
  • Use project's existing import styles and organization
  • Respect framework lifecycles and best practices

Code Structure & Modularity

  • Never create a file longer than 500 lines of code. If a file approaches this limit, refactor by splitting it into modules or helper files
  • React UI Components: Keep individual component files under 300 lines. Split complex components into smaller, focused sub-components following React's composition patterns. Extract reusable logic into custom hooks and shared utilities

AI Behavior Rules

  • Never assume missing context. Ask questions if uncertain.
  • Never hallucinate libraries or functions – only use known, verified packages
  • Always confirm file paths and module names exist before referencing them in code or tests

Systematic Codebase Changes

  • MANDATORY: Complete project-wide discovery before any changes
  • Search ALL file types for ALL variations of target terms
  • Document all references with context and impact assessment
  • Plan update sequence based on dependencies and relationships
  • Execute changes in coordinated manner following plan
  • Verify completion with comprehensive post-change search
  • Validate related functionality remains working
  • Use Task tool for comprehensive searches when scope uncertain

Code Comments

  • Avoid meaningless comments: Do not write comments that merely restate what the code does. Comments should explain why something is done, not what is being done. The code itself should be self-explanatory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment