You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This document contains universal development principles and practices for AI assistants working on any project. These principles are derived from battle-tested practices and represent a philosophy of clear, honest, and systematic development.
Required Tools and Research Methods
1. Mandatory MCP Tool Usage
BEFORE ANY ACTION, you MUST use these tools. Tool names use double underscores between segments.
Documentation Research (ALWAYS FIRST)
# BEFORE writing ANY code, search ALL relevant docs:mcp__Ref__ref_search_documentation"[language/framework] [feature] best practices 2025"mcp__Ref__ref_search_documentation"[API name] documentation"mcp__Ref__ref_search_documentation"[technology] [pattern] implementation"# Read the actual documentation URLs found:mcp__Ref__ref_read_url"[documentation URL from search]"
Refactoring plans (understand current state fully)
API integrations (error cases, rate limits, costs)
State management changes (race conditions, cleanup)
Git History Analysis
# BEFORE modifying ANY file:mcp__git__git_log --oneline -20# Recent commitsmcp__git__git_log [filename] -10# File historymcp__git__git_diff HEAD~1# What changed recently# When tests fail or CI issues:mcp__git__git_log .github/workflows/ -10# Workflow changesmcp__git__git_show [commit_hash]# Understand specific changes# Before implementing features:mcp__git__git_grep"[feature_name]"# Find related code
Code Validation Requirements
# ALWAYS run before saying "done":mcp__ide__getDiagnostics# TypeScript/ESLint errors
2. Required Questions Before Implementation
ASK QUESTIONS. LOTS OF THEM.
Before implementing features:
"What exact user experience are you envisioning?"
"Should this be configurable? What are the defaults?"
"How should this integrate with existing features?"
For error handling:
"What should happen when this fails?"
"Should errors be retried? How many times?"
"What logging/monitoring would help debug issues?"
For performance:
"Are there performance constraints I should consider?"
"What's the expected behavior on slow networks/devices?"
"How much data will this typically process?"
For security:
"Are there security implications to consider?"
"Does this handle user data? How should it be protected?"
"Are there any compliance or regulatory requirements?"
For maintenance:
"What's the migration path for existing users/data?"
"How will this be tested?"
"What documentation needs updating?"
NEVER ASSUME. ALWAYS CLARIFY.
Code Quality Standards
Clear Code Principles
Write code as if the person maintaining it is a violent psychopath who knows where you live:
Add! after type/scope:feat(api)!: remove deprecated endpoints
Or use footer:BREAKING CHANGE: description of the breaking change
Example Commit:
fix(auth): prevent race condition in token refreshAdd mutex to ensure only one token refresh happens at a time.Previous implementation could cause multiple simultaneous refreshesunder high load.Fixes: #123
Commit Requirements:
One logical change per commit
Run tests before committing
Include context for future developers
Reference issue numbers when applicable
Never mention "Claude" or "AI" in commits
Development Workflow
First Task Checklist
When given any task, ALWAYS execute these steps in order:
Or usemcp__sequential-thinking__sequentialthinking for analysis
Break into concrete steps (not timeframes)
6. Execute (varies)
Follow planned steps
Runmcp__ide__getDiagnostics after major changes
Test edge cases identified earlier
7. Validate (2-3 minutes)
/qa - Run quality checks
Verify all requirements met
Check for unintended side effects
8. Complete (1-2 minutes)
/commit - Create proper commit
Summarize what was done
Note any follow-up tasks
Slash Commands for Common Workflows
Commands located in~/.claude/commands/:
/explore [topic] - Research and plan before implementing
/qa [area] - Quality assurance and validation
/commit [type] - Create conventional commits
/map [area] - Understand code structure and dependencies
/cleanup [target] - Find and remove technical debt
/refactor [pattern] - Safe code restructuring
/debug [issue] - Systematic debugging approach
Workflow Patterns
Standard Development:
/explore → Write code → /qa → /commit
Debugging:
/debug → /map → Fix → /qa → /commit
Maintenance:
/cleanup → /refactor → /qa → /commit
Advanced Features
Extended Thinking - For complex analysis:
"Think through the architectural implications of X"
"Think step-by-step through this debugging process"
"Think about the edge cases for this implementation"
Visual Input - For UI debugging:
Paste screenshots directly when describing issues
Use with/debug for visual bug analysis
Works in interactive mode
Documentation Philosophy:
Derive documentation on-demand using slash commands
Git history is the source of truth
Keep only essential static docs (README, CONTRIBUTING)
Let code and commits tell the story
Technical Standards
Naming Conventions
Follow TypeScript/JavaScript standards:
Functions and Variables:
UsecamelCase:getUserData,processRequest
Boolean prefixes:is,has,can,should,will,did
Example:isLoading,hasPermission,canEdit
Types and Interfaces:
UsePascalCase:UserProfile,RequestHandler
NoI prefix for interfaces (useUser notIUser)
Type for data:UserData, Interface for contracts:UserService
Constants:
Global constants:SCREAMING_SNAKE_CASE (e.g.,MAX_RETRIES)
Local constants:camelCase (e.g.,defaultTimeout)
Enum values:SCREAMING_SNAKE_CASE
File Names:
Components:UserProfile.tsx
Utilities:date-helpers.ts
Types:user.types.ts
Tests:user.test.ts oruser.spec.ts
Constants:constants.ts
Planning Methodology
Always plan in concrete STEPS, not timeframes:
❌ "Week 1: Implement authentication"
✅ "Step 1: Create user model with password hashing"
✅ "Step 2: Implement JWT token generation"
✅ "Step 3: Add refresh token mechanism"
Steps are actionable and measurable. Timeframes are guesses that become lies.
Security Requirements
NEVER store secrets in code or commits
ALWAYS validate and sanitize ALL inputs
NO eval() or dynamic code execution with user data
IMPLEMENT rate limiting where appropriate
USE security headers and CSP policies
ENCRYPT sensitive data at rest and in transit
ASSUME all user input is hostile
VALIDATE permissions on every request
LOG security events for monitoring
FAIL securely - errors shouldn't leak information
Implementation Patterns
Error Handling
Use centralized error handling with proper TypeScript types:
// Import paths: @ represents project src directoryimport{withErrorHandling}from'@/shared/patterns/error-handler';// Or use relative importsimport{withErrorHandling}from'../shared/patterns/error-handler';// For async operationsconstresult=awaitwithErrorHandling(async()=>someAsyncOperation(),{operation:'fetch.user',component:'UserProfile'});// With default value on errorconstdata=awaitwithErrorHandling(async()=>fetchData(),{operation:'fetch.data'},[]// default empty array on error);// Manual error handlingtry{awaitriskyOperation();}catch(error:unknown){// Type guard before useif(errorinstanceofError){logger.error('Operation failed',error);}throwerror;// Re-throw after logging}
Type Safety
Preferunknown overany in catch blocks:
// Bad - no type safetycatch(error: any){console.log(error.message);// Could crash}// Good - type safecatch(error: unknown){if(errorinstanceofError){logger.error(error.message);}else{logger.error('Unknown error',error);}}
Performance Optimization Process
Measure first: Use browser profiler to identify bottlenecks
Analyze: Use sequential thinking to understand the issue
Implement: Apply optimization following established patterns
Verify: Measure again to confirm improvement
Document: Record the optimization and its impact
State Management Guidelines
Single source of truth: One place for each piece of state
Immutable updates: Never mutate, always create new objects
Cleanup on unmount: Remove listeners, cancel requests
Hey@rishabhsonker, how do you use this? Usually I ask Claude Code to generate the CLAUDE.md file itself and it does create it specific to the project, so not sure how to use this.