Cursor plugin for Django 5.x and Django REST Framework. Prevents N+1 queries, teaches idiomatic patterns, scaffolds full vertical slices, and covers features LLMs miss.
AI models generate Django code that is technically valid but operationally bad:
- N+1 queries in over 80% of AI-generated Django code (loops accessing related fields without
select_related/prefetch_related) CharFieldused for everything instead ofEmailField,BooleanField,DecimalField, etc.- Missing
__str__, missingMeta.ordering, missingrelated_name null=TrueonCharField/TextField(creates two "empty" states)- Business logic in views instead of models
fields = '__all__'in serializers (exposes sensitive data)- Missing pagination on list endpoints
- No knowledge of Django 5.x features (
db_default,GeneratedField,LoginRequiredMiddleware, composite primary keys)
Clone into your Cursor plugins directory:
git clone https://github.com/RoninForge/roninforge-django.git ~/.cursor/plugins/local/roninforge-djangoOr copy rules/skills into your project:
git clone https://github.com/RoninForge/roninforge-django.git
cp -r roninforge-django/rules/* your-project/.cursor/rules/
cp -r roninforge-django/skills/* your-project/.cursor/skills/
cp -r roninforge-django/agents/* your-project/.cursor/agents/| Rule | Scope | What it does |
|---|---|---|
django-core |
Always active | ORM optimization, model conventions, view patterns, URL routing, security |
django-anti-patterns |
Always active | 14 AI-specific mistakes: N+1, wrong field types, fat views, hardcoded secrets |
django-5x |
Agent-requested | Django 5.0-5.2 features: db_default, GeneratedField, LoginRequiredMiddleware, composite PKs |
django-drf |
Serializer/view files | DRF patterns: validation, permissions, pagination, filtering, nested serializers |
django-models |
models.py files | Model structure, field types, relationships, indexes, managers, constraints |
| Skill | Command | What it does |
|---|---|---|
| Model scaffold | /django-model |
Generate model + serializer + viewset + URL + admin + migration command |
| API endpoint | /django-api |
Generate a complete DRF API endpoint with permissions, filtering, pagination |
| Project audit | /django-validate |
Scan for N+1 queries, missing indexes, wrong field types, security issues |
| Settings split | /django-settings |
Split settings.py into base/development/production with env vars |
| Agent | What it does |
|---|---|
django-reviewer |
Reviews code for N+1 queries, missing optimizations, DRF anti-patterns, security |
Bundled Django 5.x reference and DRF patterns documentation sourced from official Django and DRF docs.
vs. generic .cursorrules files:
- 14 explicit anti-patterns that catch AI-specific Django mistakes
- N+1 query prevention as a first-class rule (the #1 Django performance issue)
- Full vertical slice scaffolding (model through admin), not just isolated code
- Django 5.x features that don't exist in LLM training data
- DRF-specific rules with validation, permission, and pagination enforcement
vs. no plugin:
- Prevents the top 14 AI mistakes in Django code generation
- Scaffold skill generates runnable model + serializer + viewset + URL + admin in one shot
- Validation skill catches N+1 queries and security issues before they ship
- Settings skill automates the dev/prod split that every Django project needs
The tests/ directory includes sample projects:
tests/fixtures/anti-pattern-sample/- a project with common AI-generated anti-patternstests/fixtures/correct-sample/- the same project written idiomatically
Use these to verify the validation skill catches the anti-patterns.
chmod +x tests/validation/validate-plugin.sh
./tests/validation/validate-plugin.sh- Fork the repo
- Create a branch for your change
- Run
./tests/validation/validate-plugin.shbefore submitting - Open a PR
All rule content must be verified against the official Django documentation and DRF documentation.
MIT - see LICENSE