agentleFS
speedpyspeedpy/speedpy/.cursor/rules/api.mdc

speedpy / rules

Cursor rule81 starsChanged 3 months agoMITView on GitHub

Rules for working on HTTP API endpoints under /api/v1/

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository6 other files it gives its agents.

The file

We split this api.mdc into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read AGENTS.md sections "HTTP API" and "Webhook Extension Guide" before making changes — they are the source of truth for file layout, URL …

    line 15
  2. Very specific:

    Run all Django commands from this directory (speedpy/).

    line 22
  3. Very specific:

    Every endpoint needs @extend_schema with tags, operation_id, summary, and request/response serializers.

    line 27
  4. Very specific:

    Use HasScope from speedpycom.api.permissions with required_scopes on views.

    line 29
  5. Distinctive:

    When a webhook event is needed for a new API resource, follow the

    line 42
  6. Very specific:

    Add constant to mainapp/webhooks/events.py (WebhookEvent class + ALL set).

    line 45
  7. Very specific:

    Call dispatch_event(team, event_type, data) after the DB write.

    line 46
  8. Very specific:

    Add test in mainapp/tests/test_webhooks.py.

    line 47
  9. Very specific:

    Document event in speedpy-docs/docs/webhooks.md.

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
api.mdc
---
description: Rules for working on HTTP API endpoints under /api/v1/
globs:
  - mainapp/api/**
  - speedpycom/api/**
  - usermodel/api.py
  - project/api_urls.py
  - mainapp/tests/test_api_*.py
  - mainapp/webhooks/**
  - mainapp/tasks/webhooks.py
---

# HTTP API work

Read **`AGENTS.md` sections "HTTP API" and "Webhook Extension Guide"** before
making changes — they are the source of truth for file layout, URL conventions,
serializer patterns, scopes, tenant isolation, testing requirements, and webhook
events.

## Quick rules

- Run all Django commands from this directory (`speedpy/`).
- API code lives in the **owning app**, not a separate `api` Django app.
- Business resources: `mainapp/api/<domain>.py` + route in `project/api_urls.py`.
- User/profile API: `usermodel/api.py` (single-file; do not package-split).
- Shared permissions/mixins: `speedpycom/api/`.
- Every endpoint needs `@extend_schema` with `tags`, `operation_id`, `summary`,
  and request/response serializers.
- Use `HasScope` from `speedpycom.api.permissions` with `required_scopes` on views.
- Team-scoped endpoints: resolve `team_id` from URL, verify membership, filter
  querysets through `TeamMembership`. Never trust `team_id` from request body.
- New scopes: add to `OAUTH2_PROVIDER["SCOPES"]` in `project/settings.py`
  and `SPECTACULAR_SETTINGS["APPEND_COMPONENTS"]`. The PAT form picks them up
  automatically via the scope registry in `speedpycom.api.scopes`.
- Tests in `mainapp/tests/test_api_<domain>.py`: anonymous rejection, happy path,
  field contract, tenant isolation, role boundaries, schema validation.
- Validate after changes: run `spectacular --validate --fail-on-warn` using the
  wrapper from `AGENTS-local.md`.

## Webhooks (optional)

When a webhook event is needed for a new API resource, follow the
**Webhook Extension Guide** in `AGENTS.md`. Quick checklist:

1. Add constant to `mainapp/webhooks/events.py` (`WebhookEvent` class + `ALL` set).
2. Call `dispatch_event(team, event_type, data)` after the DB write.
3. Add test in `mainapp/tests/test_webhooks.py`.
4. Document event in `speedpy-docs/docs/webhooks.md`.

## Full recipe

For the complete step-by-step (model, serializer, views, scopes, URLs, tests,
schema, webhooks, CLI/MCP examples), use the `/add-integration-api` skill.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.