Initial commit
This commit is contained in:
114
commands/code-explain.md
Normal file
114
commands/code-explain.md
Normal file
@@ -0,0 +1,114 @@
|
||||
---
|
||||
description: Deep dive into codebase to answer questions and explain functionality
|
||||
---
|
||||
|
||||
# Code Explain Command
|
||||
|
||||
You are tasked with explaining code and answering questions about the codebase with depth and clarity.
|
||||
|
||||
## Your Role
|
||||
|
||||
When a user asks a question about the codebase, you should:
|
||||
|
||||
1. **Understand the Question** - Clarify what the user is asking about
|
||||
2. **Locate Relevant Code** - Search the codebase for relevant files, functions, and modules
|
||||
3. **Analyze Thoroughly** - Read and understand the code, including dependencies and context
|
||||
4. **Explain Clearly** - Provide a comprehensive but accessible explanation
|
||||
|
||||
## Approach
|
||||
|
||||
### For "How does X work?" questions:
|
||||
|
||||
1. Locate the relevant code (functions, classes, modules)
|
||||
2. Trace the execution flow
|
||||
3. Explain the logic step-by-step
|
||||
4. Highlight key concepts and patterns
|
||||
5. Show relevant code snippets with context
|
||||
6. Explain dependencies and interactions with other parts
|
||||
7. Mention any gotchas or edge cases
|
||||
|
||||
### For "What does X do?" questions:
|
||||
|
||||
1. Find the code element (function, class, file)
|
||||
2. Explain its purpose and responsibility
|
||||
3. Describe inputs and outputs
|
||||
4. Show how it's used in the codebase
|
||||
5. Explain its role in the larger system
|
||||
|
||||
### For "Where is X implemented?" questions:
|
||||
|
||||
1. Search for the functionality across the codebase
|
||||
2. Identify the main implementation location
|
||||
3. Show related files and dependencies
|
||||
4. Explain the architecture around it
|
||||
5. Mention any configuration or environment factors
|
||||
|
||||
### For "Why is X done this way?" questions:
|
||||
|
||||
1. Examine the implementation
|
||||
2. Consider the context and requirements
|
||||
3. Explain the design decisions
|
||||
4. Discuss alternatives and tradeoffs
|
||||
5. Look for comments or documentation that explain rationale
|
||||
|
||||
## Explanation Style
|
||||
|
||||
- **Be thorough but clear** - Don't oversimplify, but make it accessible
|
||||
- **Use examples** - Show concrete code snippets when relevant
|
||||
- **Provide context** - Explain how pieces fit into the larger system
|
||||
- **Visual aids** - Use diagrams or flowcharts for complex logic when helpful
|
||||
- **Cite sources** - Reference specific files and line numbers
|
||||
- **Progressive detail** - Start with high-level overview, then dive deeper
|
||||
- **Highlight key points** - Use formatting to emphasize important information
|
||||
|
||||
## Code Snippet Format
|
||||
|
||||
When showing code:
|
||||
```
|
||||
📁 path/to/file.js (lines 45-60)
|
||||
|
||||
[relevant code snippet]
|
||||
```
|
||||
|
||||
- Show enough context to understand the code
|
||||
- Highlight the most important parts
|
||||
- Explain what the code does line-by-line if complex
|
||||
|
||||
## Example Response Structure
|
||||
|
||||
```
|
||||
## Overview
|
||||
[High-level explanation of what's being asked]
|
||||
|
||||
## Implementation Location
|
||||
[Where the relevant code lives]
|
||||
|
||||
## How It Works
|
||||
[Step-by-step explanation with code snippets]
|
||||
|
||||
## Key Components
|
||||
[Important functions, classes, or modules involved]
|
||||
|
||||
## Integration
|
||||
[How this fits into the larger system]
|
||||
|
||||
## Additional Notes
|
||||
[Edge cases, gotchas, or related information]
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Ask clarifying questions if the user's question is ambiguous
|
||||
- If code is complex, break down the explanation into logical sections
|
||||
- Point out patterns, best practices, or issues you notice
|
||||
- Suggest related code or concepts the user might want to explore
|
||||
- If you find issues or improvements, mention them constructively
|
||||
|
||||
## Remember
|
||||
|
||||
- Your goal is to help the user truly understand the code, not just answer superficially
|
||||
- Take time to search and read the relevant code thoroughly
|
||||
- Don't guess - search the codebase for accurate information
|
||||
- If something isn't clear from the code alone, say so
|
||||
- Encourage follow-up questions for deeper understanding
|
||||
|
||||
164
commands/update-claude.md
Normal file
164
commands/update-claude.md
Normal file
@@ -0,0 +1,164 @@
|
||||
---
|
||||
description: Update the CLAUDE.md file to reflect major changes in the codebase
|
||||
---
|
||||
|
||||
# Update CLAUDE.md Command
|
||||
|
||||
You should update the `CLAUDE.md` or `.claude/CLAUDE.md` file to reflect recent major changes in the codebase.
|
||||
|
||||
## Purpose
|
||||
|
||||
The CLAUDE.md file serves as a high-level guide for Claude Code (and other AI assistants) to understand:
|
||||
- Project structure and organization
|
||||
- Key architectural decisions
|
||||
- Important conventions and patterns
|
||||
- Where to find things
|
||||
- What to watch out for
|
||||
|
||||
## When to Update
|
||||
|
||||
Update CLAUDE.md after:
|
||||
- Major refactoring or restructuring
|
||||
- New features or modules added
|
||||
- Changes to architecture or patterns
|
||||
- Updates to dependencies or tooling
|
||||
- Changes to conventions or standards
|
||||
- New directories or significant file moves
|
||||
|
||||
## What to Include
|
||||
|
||||
### 1. Project Overview
|
||||
- Brief description of what the project does
|
||||
- Tech stack and key dependencies
|
||||
- Development setup instructions
|
||||
|
||||
### 2. Architecture & Structure
|
||||
```markdown
|
||||
## Project Structure
|
||||
|
||||
- `/src` - Main application code
|
||||
- `/components` - React components
|
||||
- `/services` - Business logic and API calls
|
||||
- `/utils` - Helper functions
|
||||
- `/types` - TypeScript type definitions
|
||||
- `/tests` - Test files
|
||||
- `/docs` - Documentation
|
||||
- `/scripts` - Build and utility scripts
|
||||
```
|
||||
|
||||
### 3. Key Patterns & Conventions
|
||||
- Code organization patterns
|
||||
- Naming conventions
|
||||
- State management approach
|
||||
- Error handling patterns
|
||||
- Testing strategies
|
||||
|
||||
### 4. Important Notes
|
||||
- Gotchas or common pitfalls
|
||||
- Performance considerations
|
||||
- Security requirements
|
||||
- Browser/platform support
|
||||
- Third-party integrations
|
||||
|
||||
### 5. Development Workflow
|
||||
- How to run locally
|
||||
- How to run tests
|
||||
- How to build
|
||||
- How to deploy
|
||||
- Branch strategy
|
||||
|
||||
## Format Example
|
||||
|
||||
```markdown
|
||||
# Project Name
|
||||
|
||||
## Overview
|
||||
Brief description of the project and its purpose.
|
||||
|
||||
## Tech Stack
|
||||
- Framework/Language
|
||||
- Key libraries and tools
|
||||
- Database
|
||||
- Infrastructure
|
||||
|
||||
## Project Structure
|
||||
[Detailed structure as shown above]
|
||||
|
||||
## Architecture
|
||||
Describe the high-level architecture:
|
||||
- Frontend architecture (React, state management)
|
||||
- Backend architecture (API structure, services)
|
||||
- Database design
|
||||
- External integrations
|
||||
|
||||
## Key Conventions
|
||||
- File naming: kebab-case for components, camelCase for utilities
|
||||
- Component structure: Functional components with hooks
|
||||
- State management: Redux Toolkit for global state
|
||||
- Styling: CSS Modules with BEM naming
|
||||
- Testing: Jest + React Testing Library
|
||||
|
||||
## Important Notes
|
||||
- Authentication uses JWT tokens stored in httpOnly cookies
|
||||
- API rate limiting is 100 requests per minute
|
||||
- Image uploads are handled by AWS S3
|
||||
- Background jobs use Bull queue with Redis
|
||||
|
||||
## Development
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Run locally
|
||||
npm run dev
|
||||
|
||||
# Run tests
|
||||
npm test
|
||||
|
||||
# Build for production
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Where to Find Things
|
||||
- API endpoints: `/src/routes`
|
||||
- Database models: `/src/models`
|
||||
- Authentication logic: `/src/middleware/auth.js`
|
||||
- Email templates: `/src/templates/email`
|
||||
|
||||
## Common Tasks
|
||||
- Adding a new API endpoint: Create route in `/src/routes`, add controller in `/src/controllers`
|
||||
- Adding a new database table: Create migration in `/migrations`, add model in `/src/models`
|
||||
- Adding a new React page: Create component in `/src/pages`, add route in `/src/App.js`
|
||||
```
|
||||
|
||||
## Your Task
|
||||
|
||||
1. **Locate the CLAUDE.md file** (or create it if it doesn't exist)
|
||||
- Check for `CLAUDE.md` or `.claude/CLAUDE.md`
|
||||
- If neither exists, create `.claude/CLAUDE.md`
|
||||
|
||||
2. **Review recent changes**
|
||||
- Look at git history for major changes
|
||||
- Review current project structure
|
||||
- Note any new patterns or conventions
|
||||
|
||||
3. **Update the file**
|
||||
- Add new sections for new features/modules
|
||||
- Update structure diagrams
|
||||
- Document new conventions or patterns
|
||||
- Update any outdated information
|
||||
- Add notes about recent major changes
|
||||
|
||||
4. **Keep it concise but comprehensive**
|
||||
- Focus on what's important for understanding the codebase
|
||||
- Don't duplicate documentation that exists elsewhere (link to it)
|
||||
- Highlight things that aren't obvious from the code alone
|
||||
|
||||
## Remember
|
||||
|
||||
- CLAUDE.md is a living document - it should evolve with the codebase
|
||||
- Focus on information that helps understand the big picture
|
||||
- Be specific enough to be useful, but high-level enough to stay relevant
|
||||
- Update it proactively, not just when asked
|
||||
- Think about what would help someone (or AI) new to the codebase get oriented quickly
|
||||
|
||||
Reference in New Issue
Block a user