Skip to content

RoninForge/roninforge-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

roninforge-django

Validate Plugin License: MIT GitHub release

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.

The Problem

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)
  • CharField used for everything instead of EmailField, BooleanField, DecimalField, etc.
  • Missing __str__, missing Meta.ordering, missing related_name
  • null=True on CharField/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)

Install

Clone into your Cursor plugins directory:

git clone https://github.com/RoninForge/roninforge-django.git ~/.cursor/plugins/local/roninforge-django

Or 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/

What's Included

Rules (5 files, auto-attached)

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

Skills (4 commands)

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 (1 subagent)

Agent What it does
django-reviewer Reviews code for N+1 queries, missing optimizations, DRF anti-patterns, security

Reference Docs

Bundled Django 5.x reference and DRF patterns documentation sourced from official Django and DRF docs.

What Makes This Different

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

Test Fixtures

The tests/ directory includes sample projects:

  • tests/fixtures/anti-pattern-sample/ - a project with common AI-generated anti-patterns
  • tests/fixtures/correct-sample/ - the same project written idiomatically

Use these to verify the validation skill catches the anti-patterns.

Validation

chmod +x tests/validation/validate-plugin.sh
./tests/validation/validate-plugin.sh

Contributing

  1. Fork the repo
  2. Create a branch for your change
  3. Run ./tests/validation/validate-plugin.sh before submitting
  4. Open a PR

All rule content must be verified against the official Django documentation and DRF documentation.

License

MIT - see LICENSE

Links

About

Cursor plugin for Django 5.x and DRF. N+1 query prevention, idiomatic patterns, scaffold skills, and anti-pattern detection.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages