Skip to content

Commit 6f37189

Browse files
authored
Merge pull request #8 from mugubr/v1.3.0
v1.3.0
2 parents 7ad4ec4 + 4f14f0f commit 6f37189

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+12235
-1682
lines changed

.claude/README.md

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
# Claude Code Configuration for django_base
2+
3+
This directory contains optimized Claude Code configuration for maximum
4+
productivity and token efficiency.
5+
6+
## 📁 Structure
7+
8+
```
9+
.claude/
10+
├── README.md # This file
11+
├── context.md # Project context (bilingual, token-optimized)
12+
├── settings.local.json # Claude Code settings with permissions
13+
├── agents/ # Specialized agents for different tasks
14+
│ ├── django-expert.md # Django/DRF expert
15+
│ ├── code-reviewer.md # Code quality and security reviewer
16+
│ ├── backend-architect.md # System architecture expert
17+
│ └── python-pro.md # Python optimization specialist
18+
├── scripts/
19+
│ └── context-monitor.py # Status line script (token counter)
20+
└── skills/
21+
└── mcp-builder/ # MCP server builder skill
22+
```
23+
24+
## 🎯 Core Philosophy
25+
26+
### 1. Maximum Token Economy ⚡
27+
28+
- **Edit over Rewrite**: Use `Edit` tool for modifications
29+
- **Agents for Complex Tasks**: Use specialized agents via `Task` tool
30+
- **Concise Responses**: 1-4 lines when possible, no fluff
31+
- **Smart Caching**: Leverage context caching for frequent reads
32+
33+
### 2. Bilingual Documentation 🌍
34+
35+
- **All docstrings**: English first line, Portuguese second
36+
- **Inline comments**: `# EN / PT-BR`
37+
- **Templates**: Use `{% trans %}` for i18n
38+
- **Code is globally accessible**: EN/PT-BR by default
39+
40+
### 3. Quality Assurance 🛡️
41+
42+
- **Pre-commit hooks**: 20+ quality checks
43+
- **Ruff formatting**: Auto-format on save
44+
- **Security scanning**: Bandit integration
45+
- **Test coverage**: Maintain >80%
46+
47+
## 🤖 Specialized Agents
48+
49+
### Django Expert (`django-expert`)
50+
51+
**When to use**: Django models, views, forms, serializers, DRF tasks
52+
53+
```bash
54+
# Example usage in conversation:
55+
"Use the django-expert agent to create a new API endpoint for orders"
56+
```
57+
58+
**Expertise**:
59+
60+
- Models with proper mixins (Timestamped, SoftDelete, UserTracking)
61+
- DRF ViewSets with filters, search, pagination
62+
- Forms with Bootstrap 5 widgets
63+
- Custom validators and decorators
64+
- Bilingual docstrings
65+
66+
### Code Reviewer (`code-reviewer`)
67+
68+
**When to use**: After implementing features, before commits
69+
70+
```bash
71+
# Example usage:
72+
"Use the code-reviewer agent to review my changes"
73+
```
74+
75+
**Review checklist**:
76+
77+
- Code quality (Ruff, unused imports, type hints)
78+
- Django best practices (ORM, queries, migrations)
79+
- Security (no hardcoded secrets, CSRF, XSS, SQL injection)
80+
- Project standards (bilingual docs, i18n, mixins)
81+
- Performance (N+1 queries, caching)
82+
- Testing (coverage, edge cases)
83+
84+
### Backend Architect (`backend-architect`)
85+
86+
**When to use**: Architectural decisions, database design, scalability
87+
88+
```bash
89+
# Example usage:
90+
"Use the backend-architect agent to design the notification system"
91+
```
92+
93+
**Expertise**:
94+
95+
- System architecture and API design
96+
- Database schema and relationships
97+
- Scalability planning
98+
- Performance optimization
99+
- Integration patterns
100+
101+
### Python Pro (`python-pro`)
102+
103+
**When to use**: Refactoring, optimization, advanced Python features
104+
105+
```bash
106+
# Example usage:
107+
"Use the python-pro agent to optimize the data processing pipeline"
108+
```
109+
110+
**Expertise**:
111+
112+
- Python best practices and patterns
113+
- Performance optimization
114+
- Async/await, generators, decorators
115+
- Type hints and static analysis
116+
- Code refactoring
117+
118+
## 🧠 Memory MCP Server
119+
120+
The project is configured with Memory MCP server for persistent context across
121+
sessions.
122+
123+
**Configuration**: See `.mcp.json` in project root
124+
125+
**Usage**:
126+
127+
```typescript
128+
// Memory MCP automatically persists:
129+
- Important project decisions
130+
- Architecture patterns
131+
- User preferences
132+
- Conversation context
133+
```
134+
135+
**Benefits**:
136+
137+
- Continuity across sessions
138+
- Reduced context repetition
139+
- Better long-term understanding
140+
- Faster startup with cached knowledge
141+
142+
## ⚙️ Settings Explained
143+
144+
### Permissions (`settings.local.json`)
145+
146+
**Simplified wildcard permissions** for common tools:
147+
148+
- `docker-compose:*`, `docker:*` - Docker operations
149+
- `git:*` - All git operations
150+
- `kubectl:*`, `kubectl.exe:*` - Kubernetes operations
151+
- `python:*`, `ruff:*` - Python and linting
152+
- `pre-commit:*` - Code quality hooks
153+
154+
**Denied operations** (safety):
155+
156+
- `rm -rf /` - System deletion
157+
- `dd:*` - Disk operations
158+
- Fork bombs and destructive commands
159+
160+
### Status Line
161+
162+
Shows real-time token usage via `context-monitor.py`:
163+
164+
```
165+
Tokens: 45k/200k | Files: 12 | Context: 15%
166+
```
167+
168+
## 📖 Context File (`context.md`)
169+
170+
Optimized project documentation with:
171+
172+
- **Mission and critical rules** (token economy, bilingual, workflow)
173+
- **Architecture and tech stack** (table format for quick reference)
174+
- **Design principles** (security, DX, performance, soft delete)
175+
- **Core files reference** (models, views, forms, APIs, utils)
176+
- **Common workflows** (how to create endpoints, pages, etc.)
177+
- **Quick commands** (Docker, database, testing)
178+
- **Critical info** (credentials, URLs, ports)
179+
- **Code patterns** (docstrings, forms, templates)
180+
181+
## 🚀 Best Practices
182+
183+
### When Starting a Task
184+
185+
1. **Check context**: Read `.claude/context.md` if unfamiliar
186+
2. **Plan complex tasks**: Use `TodoWrite` for 3+ steps
187+
3. **Choose the right agent**: Use specialized agents for efficiency
188+
4. **Verify state**: Run `git status` before modifications
189+
190+
### During Development
191+
192+
1. **Edit, don't rewrite**: Use `Edit` tool for changes
193+
2. **Bilingual everything**: Docstrings and comments EN/PT-BR
194+
3. **Test immediately**: Write tests with new features
195+
4. **Commit often**: Small, focused commits with bilingual messages
196+
197+
### Before Committing
198+
199+
1. **Review code**: Use `code-reviewer` agent
200+
2. **Run tests**: Ensure >80% coverage
201+
3. **Check quality**: Pre-commit hooks run automatically
202+
4. **Update docs**: If public API changed
203+
204+
## 💡 Token Optimization Tips
205+
206+
### For Users
207+
208+
1. **Be specific**: "Add user authentication" vs "Add JWT authentication with
209+
refresh tokens"
210+
2. **Use agents**: Complex tasks → specialized agents
211+
3. **Reference files**: "Edit line 42 in models.py" vs explaining the whole
212+
context
213+
4. **Batch requests**: Multiple related changes in one message
214+
215+
### For Claude
216+
217+
1. **Prefer Edit**: Modify existing code, don't rewrite
218+
2. **Concise responses**: Skip pleasantries, get to the point
219+
3. **Use memory**: Store recurring patterns, user preferences
220+
4. **Smart tool selection**: Grep before Read for large files
221+
222+
## 📚 Quick Reference
223+
224+
### File Paths
225+
226+
- **Context**: `.claude/context.md`
227+
- **Settings**: `.claude/settings.local.json`
228+
- **Agents**: `.claude/agents/*.md`
229+
- **MCP Config**: `.mcp.json` (root)
230+
231+
### Agent Invocation
232+
233+
```bash
234+
# In conversation with Claude:
235+
"Use <agent-name> to <task>"
236+
237+
# Examples:
238+
"Use django-expert to create a Product model"
239+
"Use code-reviewer to check my changes"
240+
"Use backend-architect to design the API"
241+
"Use python-pro to optimize this function"
242+
```
243+
244+
### Common Commands
245+
246+
```bash
247+
# Check token usage
248+
cat .claude/scripts/context-monitor.py
249+
250+
# View context
251+
cat .claude/context.md
252+
253+
# List agents
254+
ls .claude/agents/
255+
256+
# Check MCP config
257+
cat .mcp.json
258+
```
259+
260+
## 🔧 Maintenance
261+
262+
### Updating Context
263+
264+
When project evolves significantly:
265+
266+
1. Edit `.claude/context.md`
267+
2. Keep it concise (token-optimized)
268+
3. Update file counts, model lists, etc.
269+
4. Maintain bilingual standard
270+
271+
### Adding New Agents
272+
273+
1. Create `.claude/agents/new-agent.md`
274+
2. Define expertise and usage
275+
3. List available tools
276+
4. Add usage examples
277+
5. Document in this README
278+
279+
### Reviewing Permissions
280+
281+
Periodically check `.claude/settings.local.json`:
282+
283+
- Remove unused permissions
284+
- Add new common operations
285+
- Verify deny list is complete
286+
287+
## 📊 Metrics
288+
289+
Track these for optimization:
290+
291+
- **Token usage per session**: Aim for <50k for standard tasks
292+
- **Agent usage**: Which agents are most effective?
293+
- **Edit vs Rewrite ratio**: Higher is better
294+
- **Response length**: Shorter is better (when appropriate)
295+
296+
## 🎓 Learning Resources
297+
298+
- [Claude Code Docs](https://docs.claude.com/claude-code)
299+
- [MCP Documentation](https://modelcontextprotocol.io)
300+
- [Django Best Practices](https://docs.djangoproject.com/en/stable/misc/design-philosophies/)
301+
- [DRF Best Practices](https://www.django-rest-framework.org/topics/best-practices/)
302+
303+
---
304+
305+
**Last Updated**: 2025-10-20 **Version**: 1.0.0 **Status**: ✅ Production Ready
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: backend-architect
3+
description:
4+
Backend system architecture and API design specialist. Use PROACTIVELY for
5+
RESTful APIs, microservice boundaries, database schemas, scalability planning,
6+
and performance optimization.
7+
tools: Read, Write, Edit, Bash
8+
model: sonnet
9+
---
10+
11+
You are a backend system architect specializing in scalable API design and
12+
microservices.
13+
14+
## Focus Areas
15+
16+
- RESTful API design with proper versioning and error handling
17+
- Service boundary definition and inter-service communication
18+
- Database schema design (normalization, indexes, sharding)
19+
- Caching strategies and performance optimization
20+
- Basic security patterns (auth, rate limiting)
21+
22+
## Approach
23+
24+
1. Start with clear service boundaries
25+
2. Design APIs contract-first
26+
3. Consider data consistency requirements
27+
4. Plan for horizontal scaling from day one
28+
5. Keep it simple - avoid premature optimization
29+
30+
## Output
31+
32+
- API endpoint definitions with example requests/responses
33+
- Service architecture diagram (mermaid or ASCII)
34+
- Database schema with key relationships
35+
- List of technology recommendations with brief rationale
36+
- Potential bottlenecks and scaling considerations
37+
38+
Always provide concrete examples and focus on practical implementation over
39+
theory.

0 commit comments

Comments
 (0)