claude-initial-setup / rules
Cursor rule4 starsChanged 9 months agoMITView on GitHub
Coding standards, patterns, and best practices from claude-initial-setup skill library
- Reads credentials
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository78 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/agents.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- parallel-task-executionSkill
- subagent-patternsSkill
- task-coordinationSkill
- agent-communicationSkill
- context-managementSkill
- multi-agent-orchestrationSkill
- deploy-strategiesSkill
- github-actions-guideSkill
- pipeline-patternsSkill
- anthropic-sdk-guideSkill
- prompt-engineeringSkill
- tool-use-patternsSkill
- automated-review-setupSkill
- pr-standardsSkill
- review-checklistSkill
- file-organizationSkill
- immutability-patternsSkill
- naming-conventionsSkill
- branching-strategySkill
- commit-conventionsSkill
- pr-workflowSkill
- migration-patternsSkill
- query-optimizationSkill
- schema-design-guideSkill
- error-tracingSkill
- log-analysisSkill
- systematic-debuggingSkill
- django-admin-customizationSkill
- django-orm-masterySkill
- drf-api-patternsSkill
- docker-compose-guideSkill
- dockerfile-best-practicesSkill
- multi-stage-buildsSkill
- express-error-handlingSkill
- middleware-patternsSkill
- rest-api-nodeSkill
- async-fastapiSkill
- dependency-injection-fastapiSkill
- pydantic-validationSkill
- concurrency-patterns-goSkill
- error-handling-goSkill
- idiomatic-goSkill
- automation-triggersSkill
- hook-recipesSkill
- pre-post-hooksSkill
- junit-testingSkill
- maven-gradle-guideSkill
- spring-boot-patternsSkill
- mcp-resource-patternsSkill
- mcp-server-creationSkill
- mcp-tool-designSkill
- context-optimizationSkill
- knowledge-persistenceSkill
- memory-patternsSkill
- caching-strategiesSkill
- lazy-loading-patternsSkill
- profiling-guideSkill
- The first 60 shown.
The file
Show its rules and text
We split this claude-initial-setup.mdc into the rules it gives an agent
23 rules. About 0 are common, 19 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 11
Always create new objects instead of mutating.
- Very specific: line 34
No god files (utils.ts with 40 exports)
- Distinctive: line 39
No nesting deeper than 4 levels
- Distinctive: line 40
Use early returns and guard clauses
- Distinctive: line 69
Never force-push during review
- Distinctive: line 90
Do NOT mock: pure functions, internal utilities, code under test
- Distinctive: line 91
Always restore mocks in afterEach
- Distinctive: line 92
Use dependency injection for testability
- Distinctive: line 99
Use Zod (TS), Pydantic (Python), struct tags (Go)
- Distinctive: line 100
Prefer allowlists over denylists
- Distinctive: line 105
Always use parameterized queries or ORMs.
- Distinctive: line 118
Use framework escaping (React auto-escapes)
- Distinctive: line 124
Never hardcode secrets in source code
- Very specific: line 125
Use .env files (never committed) with schema validation at startup
- Distinctive: line 127
Use platform secret storage for CI/CD (GitHub Secrets, GitLab Variables)
- Distinctive: line 149
Always handle errors explicitly
- Distinctive: line 150
Never swallow errors silently
- Very specific: line 151
Check response.ok on fetch calls
- Distinctive: line 152
Use custom error classes for domain-specific errors
- Distinctive: line 157
Follow the loop: REPRODUCE -> HYPOTHESIZE -> TEST -> ISOLATE -> FIX -> VERIFY
- Distinctive: line 159
Use git bisect to find breaking commits
- Distinctive: line 161
Test one hypothesis at a time
- Distinctive: line 166
Avoid N+1 queries (use joins, include, select_related)
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Coding standards, patterns, and best practices from claude-initial-setup skill library
globs:
alwaysApply: true
---
# Coding Standards
## Immutability
Always create new objects instead of mutating. Use spread operators, `structuredClone`, or library solutions like immer.
```typescript
// WRONG
user.name = name;
items.push(newItem);
// CORRECT
const updated = { ...user, name };
const added = [...items, newItem];
const removed = items.filter(x => x.id !== id);
const mapped = items.map(x => x.id === id ? { ...x, ...changes } : x);
```
Python: Use `@dataclass(frozen=True)` and `replace()`. Use tuples and frozensets for immutable collections.
Go: Use value receivers and return new structs.
## File Organization
- 200-400 lines per file, 800 max
- Organize by feature/domain, not by type
- Co-locate tests next to source files
- Move to `shared/` only when used by 3+ features
- No god files (`utils.ts` with 40 exports)
## Functions
- Under 50 lines each
- No nesting deeper than 4 levels
- Use early returns and guard clauses
## Naming
- Variables: describe WHAT (`activeUsers`), not HOW (`data`)
- Booleans: `is/has/can/should` prefix (`isActive`, `hasPermission`)
- Functions: verb + noun (`getUserById`, `formatDate`, `validateEmail`)
- Collections: plural nouns (`users`, `orderItems`)
- Constants: `SCREAMING_SNAKE` (`MAX_RETRIES`, `API_BASE_URL`)
- Language casing: camelCase (JS/TS), snake_case (Python), PascalCase (Go exports)
## Git Conventions
### Commits
Format: `<type>(<scope>): <description>`
Types: feat, fix, refactor, docs, test, chore, perf, ci
Rules: imperative mood, lowercase, under 72 chars, no period
### Branches
Format: `<type>/<ticket>-<description>` in kebab-case
Types: feature/, fix/, hotfix/, release/
### Pull Requests
- Under 400 lines of changes
- Include summary, changes, test plan
- Squash merge for features, merge commit for releases
- Never force-push during review
## Testing
### TDD Workflow
1. RED: Write failing test
2. GREEN: Write minimal code to pass
3. REFACTOR: Clean up, keep tests green
4. Target 80%+ coverage
### Test Structure
- Unit tests co-located: `auth.ts` / `auth.test.ts`
- Integration tests: `test/integration/`
- E2E tests: `test/e2e/`
- Factories for dynamic data, fixtures for static data
### Mocking Rules
- Mock at boundaries: external APIs, databases, file I/O
- Do NOT mock: pure functions, internal utilities, code under test
- Always restore mocks in afterEach
- Use dependency injection for testability
## Security
### Input Validation
- Validate all user input at system boundaries
- Use Zod (TS), Pydantic (Python), struct tags (Go)
- Prefer allowlists over denylists
- Parse, then validate into typed domain objects
### SQL Injection
Always use parameterized queries or ORMs. Never concatenate user input into SQL.
```typescript
// WRONG
const q = `SELECT * FROM users WHERE email = '${email}'`;
// CORRECT
const q = 'SELECT * FROM users WHERE email = $1';
await db.query(q, [email]);
```
### XSS Prevention
- Use framework escaping (React auto-escapes)
- Sanitize with DOMPurify for rich HTML
- Set Content Security Policy headers
### Secrets
- Never hardcode secrets in source code
- Use `.env` files (never committed) with schema validation at startup
- `.gitignore`: `.env`, `.env.local`, `*.pem`, `*.key`, `credentials.json`
- Use platform secret storage for CI/CD (GitHub Secrets, GitLab Variables)
### Additional Defenses
- CSRF: anti-CSRF tokens + SameSite cookies
- SSRF: allowlist permitted domains
- IDOR: authorization check on every resource access
- Auth: bcrypt (12+ rounds), rate limiting, secure session cookies
- Headers: helmet middleware (CSP, HSTS, Referrer-Policy)
- Logging: never log passwords, tokens, or PII
## Error Handling
```typescript
try {
const result = await riskyOperation();
return result;
} catch (error) {
throw new Error(`Operation failed for ${id}: ${error.message}`);
}
```
- Always handle errors explicitly
- Never swallow errors silently
- Check `response.ok` on fetch calls
- Use custom error classes for domain-specific errors
- Return consistent API error responses with field-level detail
## Debugging
Follow the loop: REPRODUCE -> HYPOTHESIZE -> TEST -> ISOLATE -> FIX -> VERIFY
- Use `git bisect` to find breaking commits
- Create minimal reproductions
- Test one hypothesis at a time
- Fix root causes, not symptoms
## Performance
- Avoid N+1 queries (use joins, include, select_related)
- Bound queries with LIMIT/pagination
- Cache appropriately: in-memory LRU, Redis, CDN
- Set proper Cache-Control headers
- Lazy load and code split frontend bundles
## Docker
- Multi-stage builds (separate build from runtime)
- Non-root user (`USER appuser`)
- Layer caching (dependencies before source code)
- HEALTHCHECK directives
- Alpine-based images
## Database
- Normalize to 3NF, denormalize selectively for performance
- snake_case for tables, columns, indexes
- Index columns used in WHERE, JOIN, ORDER BY
- Foreign key constraints for integrity
- Zero-downtime migrations (nullable first, backfill, then constrain)
## Code Review Priority
1. Correctness: edge cases, error handling, async errors
2. Security: input validation, authorization, secrets
3. Performance: N+1 queries, unbounded results
4. Maintainability: focused functions, clear naming
5. Testing: coverage, edge cases, behavior over implementation
6. Style: enforce with linters, not review comments
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

