Skip to main content
skill CX Codex

rest-api-django — Claude Code skill for Django REST APIs

A rule set that steers your coding agent through Django REST Framework work: project layout, serializers, JWT auth, N+1 queries.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Mindrally/skills --skill rest-api-django -a claude-code
Open on GitHub

What rest-api-django does

The skill gives the agent a working frame for Django REST Framework. It covers app layout (models.py, managers.py, signals.py, tasks.py) and API layout (api/v1/ with urls.py, serializers.py, views.py, permissions.py, filters.py). Business logic stays in models, not views, and endpoints are built on DRF class-based views.

Performance and auth get their own sections. Queries should use select_related() and prefetch_related() to avoid N+1, indexes go on frequently queried fields, and transaction.atomic() wraps critical writes. Authentication leans on djangorestframework_simplejwt, permissions are set per endpoint, and session-based auth needs CSRF protection.

Errors follow one shape: a success flag, a message, a per-field errors dict and an error_code. Internal errors never reach the client. One caveat: the auth guidance assumes djangorestframework_simplejwt, so on a project without JWT you will drop part of it.

What it helps with

  • split a Django project into apps and API folders
  • kill N+1 queries with eager loading
  • wire up JWT auth and per-endpoint permissions
  • return one consistent error shape
  • add pagination and caching to list endpoints

Example prompts for the agent

  • Design the api/v1 layout for a new Django app
  • Check my views for N+1 and suggest select_related
  • Give me a single error format with error_code for DRF

How to install rest-api-django

1Skills CLI (Vercel)

npx skills add Mindrally/skills --skill rest-api-django -a claude-code

2Manually: put the files in place

~/.claude/skills/rest-api-django/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/rest-api-django/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about rest-api-django

How do I install rest-api-django in Claude?

Run npx skills add Mindrally/skills --skill rest-api-django -a claude-code. The skill file lands at ~/.claude/skills/rest-api-django/SKILL.md.

What does rest-api-django do?

It gives the agent Django REST Framework guidelines: project structure, views, models, serializers, authentication, performance and error handling.

What dependencies does the skill assume?

The auth section uses djangorestframework_simplejwt, and caching advice names Redis or Memcached. Without JWT in your project, those parts do not apply.

Source text

SKILL.md · Apache-2.0
---
name: rest-api-django
description: Comprehensive guidelines for Django REST API development covering project structure, views, models, serializers, authentication, performance, and error handling.
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# REST API Development with Django

You are an expert in Django REST Framework for building scalable APIs.

## Core Principles

- Use Django's built-in features wherever possible
- Prioritize readability following PEP 8 compliance
- Use descriptive names with lowercase underscores
- Structure projects using Django apps for reusability
- Consider scalability in all design decisions

## Project Structure

### Application Structure
```
app_name/
  migrations/       # Database migrations
  admin.py          # Admin configuration
  models.py         # Data models
  managers.py       # Custom model managers
  signals.py        # Django signals
  tasks.py          # Celery tasks
```

### API Structure
```
api/
  v1/
    urls.py         # URL routing
    serializers.py  # DRF serializers
    views.py        # API views
    permissions.py  # Custom permissions
    filters.py      # Query filters
```

## Development Guidelines

### Views and API Design
- Use class-based views with DRF's APIViews
- Follow RESTful principles for endpoint design
- Keep business logic in models, not views
- Maintain consistent response formats

### Models and Database
- Leverage Django ORM for all database operations
- Use `select_related()` and `prefetch_related()` to prevent N+1 queries
- Apply proper indexing on frequently queried fields
- Use `transaction.atomic()` for critical operations

### Serializers and Validation
- Use DRF serializers for all data transformation
- Implement custom validators for complex validation
- Handle nested relationships properly
- Keep serializers focused and composable

### Authentication and Authorization
- Use `djangorestframework_simplejwt` for JWT authentication
- Implement granular permissions per endpoint
- Ensure CSRF protection for session-based auth
- Apply principle of least privilege

### Performance Optimization
- Prevent N+1 queries through eager loading
- Implement database connection pooling
- Use Redis or Memcached for caching
- Apply standardized pagination to list endpoints

### Error Handling
```python
{
    "success": False,
    "message": "Validation failed",
    "errors": {
        "field_name": ["Error message"]
    },
    "error_code": "VALIDATION_ERROR"
}
```

- Use appropriate HTTP status codes
- Return consistent error response structure
- Apply structured logging for debugging
- Never expose internal errors to clients

© Mindrally · Apache-2.0 · Mindrally/skills

Similar skills

Everything for Backend and APIs →

From the same set168

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor