mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-01 14:43:28 +08:00
address review: remove .cursor/ duplicate, use is not None checks
Changes based on CodeRabbit review feedback: 1. Remove entire .cursor/ directory — it was an identical copy of the main skills/commands/agents/rules, causing maintenance drift. Users of Cursor can reference the canonical files directly. 2. Use explicit `is not None` checks instead of truthiness for parsed['input'] and parsed['output']. Empty strings or empty dicts are valid values that should be preserved.
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
---
|
||||
description: "Agent orchestration guidelines for parallel task execution and multi-perspective analysis"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Agent Orchestration
|
||||
|
||||
## Available Agents
|
||||
|
||||
Located in `~/.claude/agents/`:
|
||||
|
||||
| Agent | Purpose | When to Use |
|
||||
|-------|---------|-------------|
|
||||
| planner | Implementation planning | Complex features, refactoring |
|
||||
| architect | System design | Architectural decisions |
|
||||
| tdd-guide | Test-driven development | New features, bug fixes |
|
||||
| code-reviewer | Code review | After writing code |
|
||||
| security-reviewer | Security analysis | Before commits |
|
||||
| build-error-resolver | Fix build errors | When build fails |
|
||||
| e2e-runner | E2E testing | Critical user flows |
|
||||
| refactor-cleaner | Dead code cleanup | Code maintenance |
|
||||
| doc-updater | Documentation | Updating docs |
|
||||
|
||||
## Immediate Agent Usage
|
||||
|
||||
No user prompt needed:
|
||||
1. Complex feature requests - Use **planner** agent
|
||||
2. Code just written/modified - Use **code-reviewer** agent
|
||||
3. Bug fix or new feature - Use **tdd-guide** agent
|
||||
4. Architectural decision - Use **architect** agent
|
||||
|
||||
## Parallel Task Execution
|
||||
|
||||
ALWAYS use parallel Task execution for independent operations:
|
||||
|
||||
```markdown
|
||||
# GOOD: Parallel execution
|
||||
Launch 3 agents in parallel:
|
||||
1. Agent 1: Security analysis of auth module
|
||||
2. Agent 2: Performance review of cache system
|
||||
3. Agent 3: Type checking of utilities
|
||||
|
||||
# BAD: Sequential when unnecessary
|
||||
First agent 1, then agent 2, then agent 3
|
||||
```
|
||||
|
||||
## Multi-Perspective Analysis
|
||||
|
||||
For complex problems, use split role sub-agents:
|
||||
- Factual reviewer
|
||||
- Senior engineer
|
||||
- Security expert
|
||||
- Consistency reviewer
|
||||
- Redundancy checker
|
||||
@@ -1,53 +0,0 @@
|
||||
---
|
||||
description: "Core coding style rules: immutability, file organization, error handling, input validation"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Coding Style
|
||||
|
||||
## Immutability (CRITICAL)
|
||||
|
||||
ALWAYS create new objects, NEVER mutate existing ones:
|
||||
|
||||
```
|
||||
// Pseudocode
|
||||
WRONG: modify(original, field, value) → changes original in-place
|
||||
CORRECT: update(original, field, value) → returns new copy with change
|
||||
```
|
||||
|
||||
Rationale: Immutable data prevents hidden side effects, makes debugging easier, and enables safe concurrency.
|
||||
|
||||
## File Organization
|
||||
|
||||
MANY SMALL FILES > FEW LARGE FILES:
|
||||
- High cohesion, low coupling
|
||||
- 200-400 lines typical, 800 max
|
||||
- Extract utilities from large modules
|
||||
- Organize by feature/domain, not by type
|
||||
|
||||
## Error Handling
|
||||
|
||||
ALWAYS handle errors comprehensively:
|
||||
- Handle errors explicitly at every level
|
||||
- Provide user-friendly error messages in UI-facing code
|
||||
- Log detailed error context on the server side
|
||||
- Never silently swallow errors
|
||||
|
||||
## Input Validation
|
||||
|
||||
ALWAYS validate at system boundaries:
|
||||
- Validate all user input before processing
|
||||
- Use schema-based validation where available
|
||||
- Fail fast with clear error messages
|
||||
- Never trust external data (API responses, user input, file content)
|
||||
|
||||
## Code Quality Checklist
|
||||
|
||||
Before marking work complete:
|
||||
- [ ] Code is readable and well-named
|
||||
- [ ] Functions are small (<50 lines)
|
||||
- [ ] Files are focused (<800 lines)
|
||||
- [ ] No deep nesting (>4 levels)
|
||||
- [ ] Proper error handling
|
||||
- [ ] No hardcoded values (use constants or config)
|
||||
- [ ] No mutation (immutable patterns used)
|
||||
@@ -1,50 +0,0 @@
|
||||
---
|
||||
description: "Git commit message format, PR workflow, and feature implementation workflow"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Git Workflow
|
||||
|
||||
## Commit Message Format
|
||||
|
||||
```
|
||||
<type>: <description>
|
||||
|
||||
<optional body>
|
||||
```
|
||||
|
||||
Types: feat, fix, refactor, docs, test, chore, perf, ci
|
||||
|
||||
Note: Attribution disabled globally via ~/.claude/settings.json.
|
||||
|
||||
## Pull Request Workflow
|
||||
|
||||
When creating PRs:
|
||||
1. Analyze full commit history (not just latest commit)
|
||||
2. Use `git diff [base-branch]...HEAD` to see all changes
|
||||
3. Draft comprehensive PR summary
|
||||
4. Include test plan with TODOs
|
||||
5. Push with `-u` flag if new branch
|
||||
|
||||
## Feature Implementation Workflow
|
||||
|
||||
1. **Plan First**
|
||||
- Use **planner** agent to create implementation plan
|
||||
- Identify dependencies and risks
|
||||
- Break down into phases
|
||||
|
||||
2. **TDD Approach**
|
||||
- Use **tdd-guide** agent
|
||||
- Write tests first (RED)
|
||||
- Implement to pass tests (GREEN)
|
||||
- Refactor (IMPROVE)
|
||||
- Verify 80%+ coverage
|
||||
|
||||
3. **Code Review**
|
||||
- Use **code-reviewer** agent immediately after writing code
|
||||
- Address CRITICAL and HIGH issues
|
||||
- Fix MEDIUM issues when possible
|
||||
|
||||
4. **Commit & Push**
|
||||
- Detailed commit messages
|
||||
- Follow conventional commits format
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
description: "Hook system guidelines and TodoWrite best practices"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Hooks System
|
||||
|
||||
## Hook Types
|
||||
|
||||
- **PreToolUse**: Before tool execution (validation, parameter modification)
|
||||
- **PostToolUse**: After tool execution (auto-format, checks)
|
||||
- **Stop**: When session ends (final verification)
|
||||
|
||||
## Auto-Accept Permissions
|
||||
|
||||
Use with caution:
|
||||
- Enable for trusted, well-defined plans
|
||||
- Disable for exploratory work
|
||||
- Never use dangerously-skip-permissions flag
|
||||
- Configure `allowedTools` in `~/.claude.json` instead
|
||||
|
||||
## TodoWrite Best Practices
|
||||
|
||||
Use TodoWrite tool to:
|
||||
- Track progress on multi-step tasks
|
||||
- Verify understanding of instructions
|
||||
- Enable real-time steering
|
||||
- Show granular implementation steps
|
||||
|
||||
Todo list reveals:
|
||||
- Out of order steps
|
||||
- Missing items
|
||||
- Extra unnecessary items
|
||||
- Wrong granularity
|
||||
- Misinterpreted requirements
|
||||
@@ -1,36 +0,0 @@
|
||||
---
|
||||
description: "Common design patterns: skeleton projects, repository pattern, API response format"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Common Patterns
|
||||
|
||||
## Skeleton Projects
|
||||
|
||||
When implementing new functionality:
|
||||
1. Search for battle-tested skeleton projects
|
||||
2. Use parallel agents to evaluate options:
|
||||
- Security assessment
|
||||
- Extensibility analysis
|
||||
- Relevance scoring
|
||||
- Implementation planning
|
||||
3. Clone best match as foundation
|
||||
4. Iterate within proven structure
|
||||
|
||||
## Design Patterns
|
||||
|
||||
### Repository Pattern
|
||||
|
||||
Encapsulate data access behind a consistent interface:
|
||||
- Define standard operations: findAll, findById, create, update, delete
|
||||
- Concrete implementations handle storage details (database, API, file, etc.)
|
||||
- Business logic depends on the abstract interface, not the storage mechanism
|
||||
- Enables easy swapping of data sources and simplifies testing with mocks
|
||||
|
||||
### API Response Format
|
||||
|
||||
Use a consistent envelope for all API responses:
|
||||
- Include a success/status indicator
|
||||
- Include the data payload (nullable on error)
|
||||
- Include an error message field (nullable on success)
|
||||
- Include metadata for paginated responses (total, page, limit)
|
||||
@@ -1,60 +0,0 @@
|
||||
---
|
||||
description: "Performance optimization: model selection strategy, context window management, extended thinking"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Performance Optimization
|
||||
|
||||
## Model Selection Strategy
|
||||
|
||||
**Haiku 4.5** (90% of Sonnet capability, 3x cost savings):
|
||||
- Lightweight agents with frequent invocation
|
||||
- Pair programming and code generation
|
||||
- Worker agents in multi-agent systems
|
||||
|
||||
**Sonnet 4.6** (Best coding model):
|
||||
- Main development work
|
||||
- Orchestrating multi-agent workflows
|
||||
- Complex coding tasks
|
||||
|
||||
**Opus 4.5** (Deepest reasoning):
|
||||
- Complex architectural decisions
|
||||
- Maximum reasoning requirements
|
||||
- Research and analysis tasks
|
||||
|
||||
## Context Window Management
|
||||
|
||||
Avoid last 20% of context window for:
|
||||
- Large-scale refactoring
|
||||
- Feature implementation spanning multiple files
|
||||
- Debugging complex interactions
|
||||
|
||||
Lower context sensitivity tasks:
|
||||
- Single-file edits
|
||||
- Independent utility creation
|
||||
- Documentation updates
|
||||
- Simple bug fixes
|
||||
|
||||
## Extended Thinking + Plan Mode
|
||||
|
||||
Extended thinking is enabled by default, reserving up to 31,999 tokens for internal reasoning.
|
||||
|
||||
Control extended thinking via:
|
||||
- **Toggle**: Option+T (macOS) / Alt+T (Windows/Linux)
|
||||
- **Config**: Set `alwaysThinkingEnabled` in `~/.claude/settings.json`
|
||||
- **Budget cap**: `export MAX_THINKING_TOKENS=10000`
|
||||
- **Verbose mode**: Ctrl+O to see thinking output
|
||||
|
||||
For complex tasks requiring deep reasoning:
|
||||
1. Ensure extended thinking is enabled (on by default)
|
||||
2. Enable **Plan Mode** for structured approach
|
||||
3. Use multiple critique rounds for thorough analysis
|
||||
4. Use split role sub-agents for diverse perspectives
|
||||
|
||||
## Build Troubleshooting
|
||||
|
||||
If build fails:
|
||||
1. Use **build-error-resolver** agent
|
||||
2. Analyze error messages
|
||||
3. Fix incrementally
|
||||
4. Verify after each fix
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
description: "Mandatory security checks, secret management, and security response protocol"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Security Guidelines
|
||||
|
||||
## Mandatory Security Checks
|
||||
|
||||
Before ANY commit:
|
||||
- [ ] No hardcoded secrets (API keys, passwords, tokens)
|
||||
- [ ] All user inputs validated
|
||||
- [ ] SQL injection prevention (parameterized queries)
|
||||
- [ ] XSS prevention (sanitized HTML)
|
||||
- [ ] CSRF protection enabled
|
||||
- [ ] Authentication/authorization verified
|
||||
- [ ] Rate limiting on all endpoints
|
||||
- [ ] Error messages don't leak sensitive data
|
||||
|
||||
## Secret Management
|
||||
|
||||
- NEVER hardcode secrets in source code
|
||||
- ALWAYS use environment variables or a secret manager
|
||||
- Validate that required secrets are present at startup
|
||||
- Rotate any secrets that may have been exposed
|
||||
|
||||
## Security Response Protocol
|
||||
|
||||
If security issue found:
|
||||
1. STOP immediately
|
||||
2. Use **security-reviewer** agent
|
||||
3. Fix CRITICAL issues before continuing
|
||||
4. Rotate any exposed secrets
|
||||
5. Review entire codebase for similar issues
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
description: "Testing requirements: 80% minimum coverage, TDD workflow, test types"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Testing Requirements
|
||||
|
||||
## Minimum Test Coverage: 80%
|
||||
|
||||
Test Types (ALL required):
|
||||
1. **Unit Tests** - Individual functions, utilities, components
|
||||
2. **Integration Tests** - API endpoints, database operations
|
||||
3. **E2E Tests** - Critical user flows (framework chosen per language)
|
||||
|
||||
## Test-Driven Development
|
||||
|
||||
MANDATORY workflow:
|
||||
1. Write test first (RED)
|
||||
2. Run test - it should FAIL
|
||||
3. Write minimal implementation (GREEN)
|
||||
4. Run test - it should PASS
|
||||
5. Refactor (IMPROVE)
|
||||
6. Verify coverage (80%+)
|
||||
|
||||
## Troubleshooting Test Failures
|
||||
|
||||
1. Use **tdd-guide** agent
|
||||
2. Check test isolation
|
||||
3. Verify mocks are correct
|
||||
4. Fix implementation, not tests (unless tests are wrong)
|
||||
|
||||
## Agent Support
|
||||
|
||||
- **tdd-guide** - Use PROACTIVELY for new features, enforces write-tests-first
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
description: "Development context: active coding mode with implementation-first priorities"
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Development Context
|
||||
|
||||
Mode: Active development
|
||||
Focus: Implementation, coding, building features
|
||||
|
||||
## Behavior
|
||||
- Write code first, explain after
|
||||
- Prefer working solutions over perfect solutions
|
||||
- Run tests after changes
|
||||
- Keep commits atomic
|
||||
|
||||
## Priorities
|
||||
1. Get it working
|
||||
2. Get it right
|
||||
3. Get it clean
|
||||
|
||||
## Tools to favor
|
||||
- Edit, Write for code changes
|
||||
- Bash for running tests/builds
|
||||
- Grep, Glob for finding code
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
description: "Research context: exploration mode with understanding-before-acting approach"
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Research Context
|
||||
|
||||
Mode: Exploration, investigation, learning
|
||||
Focus: Understanding before acting
|
||||
|
||||
## Behavior
|
||||
- Read widely before concluding
|
||||
- Ask clarifying questions
|
||||
- Document findings as you go
|
||||
- Don't write code until understanding is clear
|
||||
|
||||
## Research Process
|
||||
1. Understand the question
|
||||
2. Explore relevant code/docs
|
||||
3. Form hypothesis
|
||||
4. Verify with evidence
|
||||
5. Summarize findings
|
||||
|
||||
## Tools to favor
|
||||
- Read for understanding code
|
||||
- Grep, Glob for finding patterns
|
||||
- WebSearch, WebFetch for external docs
|
||||
- Task with Explore agent for codebase questions
|
||||
|
||||
## Output
|
||||
Findings first, recommendations second
|
||||
@@ -1,27 +0,0 @@
|
||||
---
|
||||
description: "Code review context: PR review mode with severity-prioritized analysis"
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Code Review Context
|
||||
|
||||
Mode: PR review, code analysis
|
||||
Focus: Quality, security, maintainability
|
||||
|
||||
## Behavior
|
||||
- Read thoroughly before commenting
|
||||
- Prioritize issues by severity (critical > high > medium > low)
|
||||
- Suggest fixes, don't just point out problems
|
||||
- Check for security vulnerabilities
|
||||
|
||||
## Review Checklist
|
||||
- [ ] Logic errors
|
||||
- [ ] Edge cases
|
||||
- [ ] Error handling
|
||||
- [ ] Security (injection, auth, secrets)
|
||||
- [ ] Performance
|
||||
- [ ] Readability
|
||||
- [ ] Test coverage
|
||||
|
||||
## Output Format
|
||||
Group findings by file, severity first
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
description: "Go coding style: gofmt mandatory, small interfaces, error wrapping with context"
|
||||
globs: ["**/*.go"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Go Coding Style
|
||||
|
||||
> This file extends [common/coding-style.md](../common/coding-style.md) with Go specific content.
|
||||
|
||||
## Formatting
|
||||
|
||||
- **gofmt** and **goimports** are mandatory — no style debates
|
||||
|
||||
## Design Principles
|
||||
|
||||
- Accept interfaces, return structs
|
||||
- Keep interfaces small (1-3 methods)
|
||||
|
||||
## Error Handling
|
||||
|
||||
Always wrap errors with context:
|
||||
|
||||
```go
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create user: %w", err)
|
||||
}
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
See skill: `golang-patterns` for comprehensive Go idioms and patterns.
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
description: "Go hooks: gofmt/goimports auto-format, go vet, staticcheck"
|
||||
globs: ["**/*.go"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Go Hooks
|
||||
|
||||
> This file extends [common/hooks.md](../common/hooks.md) with Go specific content.
|
||||
|
||||
## PostToolUse Hooks
|
||||
|
||||
Configure in `~/.claude/settings.json`:
|
||||
|
||||
- **gofmt/goimports**: Auto-format `.go` files after edit
|
||||
- **go vet**: Run static analysis after editing `.go` files
|
||||
- **staticcheck**: Run extended static checks on modified packages
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
description: "Go patterns: functional options, small interfaces, dependency injection"
|
||||
globs: ["**/*.go"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Go Patterns
|
||||
|
||||
> This file extends [common/patterns.md](../common/patterns.md) with Go specific content.
|
||||
|
||||
## Functional Options
|
||||
|
||||
```go
|
||||
type Option func(*Server)
|
||||
|
||||
func WithPort(port int) Option {
|
||||
return func(s *Server) { s.port = port }
|
||||
}
|
||||
|
||||
func NewServer(opts ...Option) *Server {
|
||||
s := &Server{port: 8080}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
return s
|
||||
}
|
||||
```
|
||||
|
||||
## Small Interfaces
|
||||
|
||||
Define interfaces where they are used, not where they are implemented.
|
||||
|
||||
## Dependency Injection
|
||||
|
||||
Use constructor functions to inject dependencies:
|
||||
|
||||
```go
|
||||
func NewUserService(repo UserRepository, logger Logger) *UserService {
|
||||
return &UserService{repo: repo, logger: logger}
|
||||
}
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
See skill: `golang-patterns` for comprehensive Go patterns including concurrency, error handling, and package organization.
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
description: "Go security: environment variable secrets, gosec static analysis, context timeouts"
|
||||
globs: ["**/*.go"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Go Security
|
||||
|
||||
> This file extends [common/security.md](../common/security.md) with Go specific content.
|
||||
|
||||
## Secret Management
|
||||
|
||||
```go
|
||||
apiKey := os.Getenv("OPENAI_API_KEY")
|
||||
if apiKey == "" {
|
||||
log.Fatal("OPENAI_API_KEY not configured")
|
||||
}
|
||||
```
|
||||
|
||||
## Security Scanning
|
||||
|
||||
- Use **gosec** for static security analysis:
|
||||
```bash
|
||||
gosec ./...
|
||||
```
|
||||
|
||||
## Context & Timeouts
|
||||
|
||||
Always use `context.Context` for timeout control:
|
||||
|
||||
```go
|
||||
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
```
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
description: "Go testing: table-driven tests, race detection, coverage reporting"
|
||||
globs: ["**/*.go"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Go Testing
|
||||
|
||||
> This file extends [common/testing.md](../common/testing.md) with Go specific content.
|
||||
|
||||
## Framework
|
||||
|
||||
Use the standard `go test` with **table-driven tests**.
|
||||
|
||||
## Race Detection
|
||||
|
||||
Always run with the `-race` flag:
|
||||
|
||||
```bash
|
||||
go test -race ./...
|
||||
```
|
||||
|
||||
## Coverage
|
||||
|
||||
```bash
|
||||
go test -cover ./...
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
See skill: `golang-testing` for detailed Go testing patterns and helpers.
|
||||
@@ -1,36 +0,0 @@
|
||||
---
|
||||
description: "Guidance on achieving hook-like functionality in Cursor IDE"
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Hooks Guidance for Cursor
|
||||
|
||||
Cursor does not have a native hooks system like Claude Code's PreToolUse/PostToolUse/Stop hooks. However, you can achieve similar automation through:
|
||||
|
||||
## Formatting on Save
|
||||
|
||||
Configure your editor settings to run formatters on save:
|
||||
- **TypeScript/JavaScript**: Prettier, ESLint with `--fix`
|
||||
- **Python**: Black, Ruff
|
||||
- **Go**: gofmt, goimports
|
||||
|
||||
## Linting Integration
|
||||
|
||||
Use Cursor's built-in linter support:
|
||||
- ESLint for TypeScript/JavaScript
|
||||
- Ruff/Flake8 for Python
|
||||
- golangci-lint for Go
|
||||
|
||||
## Pre-Commit Hooks
|
||||
|
||||
Use git pre-commit hooks (via tools like `husky` or `pre-commit`) for:
|
||||
- Running formatters before commit
|
||||
- Checking for console.log/print statements
|
||||
- Running type checks
|
||||
- Validating no hardcoded secrets
|
||||
|
||||
## CI/CD Checks
|
||||
|
||||
For checks that ran as Stop hooks in Claude Code:
|
||||
- Add them to your CI/CD pipeline instead
|
||||
- GitHub Actions, GitLab CI, etc.
|
||||
@@ -1,43 +0,0 @@
|
||||
---
|
||||
description: "Python coding style: PEP 8, type annotations, frozen dataclasses, black/isort/ruff formatting"
|
||||
globs: ["**/*.py"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Python Coding Style
|
||||
|
||||
> This file extends [common/coding-style.md](../common/coding-style.md) with Python specific content.
|
||||
|
||||
## Standards
|
||||
|
||||
- Follow **PEP 8** conventions
|
||||
- Use **type annotations** on all function signatures
|
||||
|
||||
## Immutability
|
||||
|
||||
Prefer immutable data structures:
|
||||
|
||||
```python
|
||||
from dataclasses import dataclass
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class User:
|
||||
name: str
|
||||
email: str
|
||||
|
||||
from typing import NamedTuple
|
||||
|
||||
class Point(NamedTuple):
|
||||
x: float
|
||||
y: float
|
||||
```
|
||||
|
||||
## Formatting
|
||||
|
||||
- **black** for code formatting
|
||||
- **isort** for import sorting
|
||||
- **ruff** for linting
|
||||
|
||||
## Reference
|
||||
|
||||
See skill: `python-patterns` for comprehensive Python idioms and patterns.
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
description: "Python hooks: black/ruff auto-format, mypy/pyright type checking, print() warnings"
|
||||
globs: ["**/*.py"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Python Hooks
|
||||
|
||||
> This file extends [common/hooks.md](../common/hooks.md) with Python specific content.
|
||||
|
||||
## PostToolUse Hooks
|
||||
|
||||
Configure in `~/.claude/settings.json`:
|
||||
|
||||
- **black/ruff**: Auto-format `.py` files after edit
|
||||
- **mypy/pyright**: Run type checking after editing `.py` files
|
||||
|
||||
## Warnings
|
||||
|
||||
- Warn about `print()` statements in edited files (use `logging` module instead)
|
||||
@@ -1,40 +0,0 @@
|
||||
---
|
||||
description: "Python patterns: Protocol for duck typing, dataclass DTOs, context managers, generators"
|
||||
globs: ["**/*.py"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Python Patterns
|
||||
|
||||
> This file extends [common/patterns.md](../common/patterns.md) with Python specific content.
|
||||
|
||||
## Protocol (Duck Typing)
|
||||
|
||||
```python
|
||||
from typing import Protocol
|
||||
|
||||
class Repository(Protocol):
|
||||
def find_by_id(self, id: str) -> dict | None: ...
|
||||
def save(self, entity: dict) -> dict: ...
|
||||
```
|
||||
|
||||
## Dataclasses as DTOs
|
||||
|
||||
```python
|
||||
from dataclasses import dataclass
|
||||
|
||||
@dataclass
|
||||
class CreateUserRequest:
|
||||
name: str
|
||||
email: str
|
||||
age: int | None = None
|
||||
```
|
||||
|
||||
## Context Managers & Generators
|
||||
|
||||
- Use context managers (`with` statement) for resource management
|
||||
- Use generators for lazy evaluation and memory-efficient iteration
|
||||
|
||||
## Reference
|
||||
|
||||
See skill: `python-patterns` for comprehensive patterns including decorators, concurrency, and package organization.
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
description: "Python security: dotenv secret management, bandit static analysis"
|
||||
globs: ["**/*.py"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Python Security
|
||||
|
||||
> This file extends [common/security.md](../common/security.md) with Python specific content.
|
||||
|
||||
## Secret Management
|
||||
|
||||
```python
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
api_key = os.environ["OPENAI_API_KEY"] # Raises KeyError if missing
|
||||
```
|
||||
|
||||
## Security Scanning
|
||||
|
||||
- Use **bandit** for static security analysis:
|
||||
```bash
|
||||
bandit -r src/
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
See skill: `django-security` for Django-specific security guidelines (if applicable).
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
description: "Python testing: pytest framework, coverage reporting, test categorization with markers"
|
||||
globs: ["**/*.py"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Python Testing
|
||||
|
||||
> This file extends [common/testing.md](../common/testing.md) with Python specific content.
|
||||
|
||||
## Framework
|
||||
|
||||
Use **pytest** as the testing framework.
|
||||
|
||||
## Coverage
|
||||
|
||||
```bash
|
||||
pytest --cov=src --cov-report=term-missing
|
||||
```
|
||||
|
||||
## Test Organization
|
||||
|
||||
Use `pytest.mark` for test categorization:
|
||||
|
||||
```python
|
||||
import pytest
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_calculate_total():
|
||||
...
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_database_connection():
|
||||
...
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
See skill: `python-testing` for detailed pytest patterns and fixtures.
|
||||
@@ -1,64 +0,0 @@
|
||||
---
|
||||
description: "TypeScript/JavaScript coding style: immutability with spread operator, Zod validation, async error handling"
|
||||
globs: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# TypeScript/JavaScript Coding Style
|
||||
|
||||
> This file extends [common/coding-style.md](../common/coding-style.md) with TypeScript/JavaScript specific content.
|
||||
|
||||
## Immutability
|
||||
|
||||
Use spread operator for immutable updates:
|
||||
|
||||
```typescript
|
||||
// WRONG: Mutation
|
||||
function updateUser(user, name) {
|
||||
user.name = name // MUTATION!
|
||||
return user
|
||||
}
|
||||
|
||||
// CORRECT: Immutability
|
||||
function updateUser(user, name) {
|
||||
return {
|
||||
...user,
|
||||
name
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
Use async/await with try-catch:
|
||||
|
||||
```typescript
|
||||
try {
|
||||
const result = await riskyOperation()
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Operation failed:', error)
|
||||
throw new Error('Detailed user-friendly message')
|
||||
}
|
||||
```
|
||||
|
||||
## Input Validation
|
||||
|
||||
Use Zod for schema-based validation:
|
||||
|
||||
```typescript
|
||||
import { z } from 'zod'
|
||||
|
||||
const schema = z.object({
|
||||
email: z.string().email(),
|
||||
age: z.number().int().min(0).max(150)
|
||||
})
|
||||
|
||||
const validated = schema.parse(input)
|
||||
```
|
||||
|
||||
## Console.log
|
||||
|
||||
- No `console.log` statements in production code
|
||||
- Use proper logging libraries instead
|
||||
- See hooks for automatic detection
|
||||
@@ -1,21 +0,0 @@
|
||||
---
|
||||
description: "TypeScript/JavaScript hooks: Prettier auto-format, tsc checks, console.log warnings"
|
||||
globs: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# TypeScript/JavaScript Hooks
|
||||
|
||||
> This file extends [common/hooks.md](../common/hooks.md) with TypeScript/JavaScript specific content.
|
||||
|
||||
## PostToolUse Hooks
|
||||
|
||||
Configure in `~/.claude/settings.json`:
|
||||
|
||||
- **Prettier**: Auto-format JS/TS files after edit
|
||||
- **TypeScript check**: Run `tsc` after editing `.ts`/`.tsx` files
|
||||
- **console.log warning**: Warn about `console.log` in edited files
|
||||
|
||||
## Stop Hooks
|
||||
|
||||
- **console.log audit**: Check all modified files for `console.log` before session ends
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
description: "TypeScript/JavaScript patterns: API response interface, React hooks, repository pattern"
|
||||
globs: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# TypeScript/JavaScript Patterns
|
||||
|
||||
> This file extends [common/patterns.md](../common/patterns.md) with TypeScript/JavaScript specific content.
|
||||
|
||||
## API Response Format
|
||||
|
||||
```typescript
|
||||
interface ApiResponse<T> {
|
||||
success: boolean
|
||||
data?: T
|
||||
error?: string
|
||||
meta?: {
|
||||
total: number
|
||||
page: number
|
||||
limit: number
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Custom Hooks Pattern
|
||||
|
||||
```typescript
|
||||
export function useDebounce<T>(value: T, delay: number): T {
|
||||
const [debouncedValue, setDebouncedValue] = useState<T>(value)
|
||||
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => setDebouncedValue(value), delay)
|
||||
return () => clearTimeout(handler)
|
||||
}, [value, delay])
|
||||
|
||||
return debouncedValue
|
||||
}
|
||||
```
|
||||
|
||||
## Repository Pattern
|
||||
|
||||
```typescript
|
||||
interface Repository<T> {
|
||||
findAll(filters?: Filters): Promise<T[]>
|
||||
findById(id: string): Promise<T | null>
|
||||
create(data: CreateDto): Promise<T>
|
||||
update(id: string, data: UpdateDto): Promise<T>
|
||||
delete(id: string): Promise<void>
|
||||
}
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
---
|
||||
description: "TypeScript/JavaScript security: environment variable secrets, security-reviewer agent"
|
||||
globs: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# TypeScript/JavaScript Security
|
||||
|
||||
> This file extends [common/security.md](../common/security.md) with TypeScript/JavaScript specific content.
|
||||
|
||||
## Secret Management
|
||||
|
||||
```typescript
|
||||
// NEVER: Hardcoded secrets
|
||||
const apiKey = "sk-proj-xxxxx"
|
||||
|
||||
// ALWAYS: Environment variables
|
||||
const apiKey = process.env.OPENAI_API_KEY
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error('OPENAI_API_KEY not configured')
|
||||
}
|
||||
```
|
||||
|
||||
## Agent Support
|
||||
|
||||
- Use **security-reviewer** skill for comprehensive security audits
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
description: "TypeScript/JavaScript testing: Playwright E2E, e2e-runner agent"
|
||||
globs: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# TypeScript/JavaScript Testing
|
||||
|
||||
> This file extends [common/testing.md](../common/testing.md) with TypeScript/JavaScript specific content.
|
||||
|
||||
## E2E Testing
|
||||
|
||||
Use **Playwright** as the E2E testing framework for critical user flows.
|
||||
|
||||
## Agent Support
|
||||
|
||||
- **e2e-runner** - Playwright E2E testing specialist
|
||||
Reference in New Issue
Block a user