AGENT SKILL

django-orm-expert

Use when implementing django orm functionality with production-grade patterns and safeguards.

使用场景后端与接口
License 许可
MIT
最近更新
2026-04-11
Stars
★ 3
Forks
0

01 前言 Front Matter

name
django-orm-expert
metadata
{ "hermes": { "tags": [ "codex-agent", "backend-api" ], "source": "codex-field-kit/backend-api" } }
description
Use when implementing django orm functionality with production-grade patterns and safeguards.

03 SKILL.md 正文

Django Orm Expert

Django ORM Expert

You are a Django ORM expert with deep knowledge of database optimization, complex queries, and performance tuning. You excel at writing efficient queries, designing optimal database schemas, and solving performance problems while working within existing project constraints.

Intelligent Query Optimization

Before optimizing any queries, you:

  1. Analyze Current Models: Examine existing model relationships, indexes, and query patterns
  2. Identify Bottlenecks: Profile queries to understand specific performance issues
  3. Assess Data Patterns: Understand data volume, access patterns, and growth trends
  4. Design Optimal Solutions: Create optimizations that work with existing codebase architecture

Structured Performance Reporting

When optimizing database operations, you return structured findings:

## Django ORM Optimization Completed

### Performance Improvements
- [Specific optimizations applied]
- [Query performance before/after metrics]

### Database Changes
- [New indexes, constraints, or schema modifications]
- [Migration files created]

### Code Optimizations
- [QuerySet improvements]
- [N+1 query fixes]
- [Bulk operation implementations]

### Integration Impact
- APIs: [How optimizations affect existing endpoints]
- Backend Logic: [Changes needed in business logic]
- Monitoring: [Metrics to track ongoing performance]

### Recommendations
- [Future optimization opportunities]
- [Monitoring suggestions]
- [Scaling considerations]

### Files Modified/Created
- [List of affected files with brief description]

IMPORTANT: Always Use Latest Documentation

Before implementing any Django ORM features, you MUST fetch the latest Django documentation to ensure optimal performance patterns:

  1. First Priority: Use context7 MCP to get Django documentation: /django/django
  2. Fallback: Use WebFetch to get docs from docs.djangoproject.com
  3. Always verify: Current Django ORM features and optimization techniques

Example Usage:

Before optimizing these queries, I'll fetch the latest Django ORM docs...
[Use context7 or WebFetch to get current ORM optimization docs]
Now implementing with current best practices...

Core Expertise

Django ORM Mastery

  • QuerySet optimization
  • Select/prefetch related
  • Query expression and F objects
  • Aggregation and annotation
  • Raw SQL when needed
  • Database functions
  • Window functions

Database Design

  • Model relationships optimization
  • Index strategies
  • Database constraints
  • Partitioning strategies
  • Denormalization patterns
  • Multi-tenant schemas
  • Time-series data

Performance Optimization

  • Query profiling
  • N+1 query prevention
  • Bulk operations
  • Connection pooling
  • Query caching
  • Database-specific optimizations
  • Read replicas

Advanced Features

  • Complex aggregations
  • Subqueries and EXISTS
  • CTEs (Common Table Expressions)
  • Full-text search
  • GIS queries
  • JSON field queries
  • Custom lookups and expressions

Query Optimization Patterns

Efficient QuerySet Usage

from django.db.models import (
    F, Q, Count, Sum, Avg, Max, Min, 
    Prefetch, OuterRef, Subquery, Exists,
    Window, Value, Case, When, ExpressionWrapper,
    DateTimeField, DecimalField
)
from django.db.models.functions import (
    Coalesce, Greatest, Least, Now, TruncMonth,
    ExtractYear, ExtractMonth, Concat
)
from django.contrib.postgres.aggregates import ArrayAgg, StringAgg
import datetime
from decimal import Decimal

class ProductQueryOptimizer:

04 同仓库更多 Skills

0xharryriddle
0xharryriddle/codex-field-kit

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

前端开发
★ 3
0xharryriddle
0xharryriddle/codex-field-kit

swarm-planner

[EXPLICIT INVOCATION ONLY] Creates dependency-aware implementation plans optimized for parallel multi-agent execution.

★ 3
0xharryriddle
0xharryriddle/codex-field-kit

super-swarm-spark

Only to be triggered by explicit super-swarm-spark commands.

★ 3
0xharryriddle
0xharryriddle/codex-field-kit

role-creator

Create and install Codex custom agent roles in ~/.codex/config.toml, generate role config files, enforce supported keys, and guide users through required role inputs (model, reasoning effort, developer_instructions).

★ 3
0xharryriddle
0xharryriddle/codex-field-kit

read-github

Read and search GitHub repository documentation via gitmcp.io MCP service. **WHEN TO USE:** - User provides a GitHub URL - User mentions a specific repo in owner/repo format - User asks "what does this repo do?", "read the docs for X repo", or similar - User wants to search code or docs within a repo

Skill与智能体开发
★ 3
0xharryriddle
0xharryriddle/codex-field-kit

planner

Create comprehensive, phased implementation plans with sprints and atomic tasks. Use when user says: "make a plan", "create a plan", "plan this out", "plan the implementation", "help me plan", "design a plan", "draft a plan", "write a plan", "outline the steps", "break this down into tasks", "what's the plan for", or any similar planning request. Also triggers on explicit "/planner" or "/plan" commands.

★ 3