codebase-guide
Skill1 starsChanged 5 months agoMITView on GitHub
The master map for building a feature end to end on this Django 5.2 / DRF 3.16 + Next.js stack — the model to serializer to ViewSet to urls/router to tests pipeline, every step tenant-scoped by the entreprise FK and gated by {resource}_{action} RBAC. Use when starting a new feature, adding an endpoint or app, onboarding to the conventions, asking "how is a feature built here" or "where does this go", or reviewing that a change follows house rules. Points to specialist skills for depth. Not for the deep mechanics of one layer — see multi-tenancy, drf-api, rbac-permissions, migrations, or write-tests for that.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- dimitritholen/1337-claudetheir own version, first seen Sep 23, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- dimitritholen/1337-claude★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository49 other files it gives its agents.
- accessibilitySkill
- ai-evalsSkill
- ai-integrationSkill
- architecture-decisionsSkill
- audit-loggingSkill
- aws-servicesSkill
- browser-e2e-testingSkill
- celery-tasksSkill
- changelogSkill
- ci-cdSkill
- code-reviewSkill
- commit-messageSkill
- cookie-auth-csrfSkill
- dashboard-data-designSkill
- db-concurrencySkill
- debugSkill
- dependency-auditSkill
- deploy-awsSkill
- design-systemSkill
- drf-apiSkill
- drf-zod-contractSkill
- frontend-perfSkill
- git-workflowSkill
- i18n-rtlSkill
- incident-responseSkill
- migrationsSkill
- money-decimalSkill
- multi-tenancySkill
- nextjs-moduleSkill
- observabilitySkill
- perf-reviewSkill
- production-readinessSkill
- product-ux-designSkill
- rbac-permissionsSkill
- react-querySkill
- security-reviewSkill
- skill-authoringSkill
- tailwind-shadcnSkill
- tenant-session-switchSkill
- threat-modelingSkill
- verifySkill
- version-checkSkill
- visual-ui-designSkill
- webhook-handlerSkill
- websockets-channelsSkill
- write-testsSkill
- zod-formsSkill
- zustand-stateSkill
- example-skillSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Every business feature flows through the same five files, in order: models.py (tenant FK) → serializers.py (field shape) → views.py/ViewSet …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill 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.
Files
Codebase guide (how a feature is built end to end)
When to use
Starting any new feature, endpoint, or app, or checking that a change follows the house conventions. This is the map; the specialist skills are the terrain. Read it first, then dive into the layer you are touching.
Pattern
Every business feature flows through the same five files, in order:
models.py (tenant FK) → serializers.py (field shape) → views.py/ViewSet
(scope + RBAC) → urls.py/router (route name) → tests.py (isolation test).
Two invariants ride along every step and are non-negotiable on a new endpoint:
- Tenant scope — the row is filtered/stamped by the current
entreprise(fail-closed), never trusted from the client (seemulti-tenancy). - RBAC gate — access is gated by a
{resource}_{action}permission (seerbac-permissions).
A worked example, one file per step (migration follows the model — see migrations):
# invoices/models.py
class Invoice(models.Model):
entreprise = models.ForeignKey( # rename to your tenant FK
"tenants.Entreprise", on_delete=models.CASCADE,
null=False, related_name="invoices")
number = models.CharField(max_length=32)
class Meta:
indexes = [models.Index(fields=["entreprise"])] # every filter hits it
# invoices/serializers.py (see drf-api)
class InvoiceSerializer(serializers.ModelSerializer):
class Meta:
model = Invoice
fields = ["id", "number", "entreprise"]
read_only_fields = ["entreprise"] # server stamps it, not the client
# invoices/views.py — both invariants enforced here
class InvoiceViewSet(TenantScopedViewSet): # get_queryset filters by tenant
serializer_class = InvoiceSerializer
queryset = Invoice.objects.all()
permission_classes = [HasResourcePermission] # gates by invoice_{action}
perm_base = "invoice" # matches rbac-permissions -> invoice_read/create/...
# invoices/urls.py — basename gives reversible route names; mount under /api/
router = DefaultRouter()
router.register("invoices", InvoiceViewSet, basename="invoice")
# invoices/tests.py — the mandatory tenant-isolation test (see write-tests)
def test_tenant_isolation(self):
self.client.cookies = self.user_a_cookies # user A must NOT see B's invoice
resp = self.client.get(f"/api/invoices/{self.invoice_b.id}/")
assert resp.status_code == 404 # scoped queryset -> 404, not 403Conventions on every change:
- New endpoint ⇒ tenant filter and RBAC permission, both. A filter with no gate leaks within the tenant; a gate with no filter leaks across tenants.
- One app per bounded resource; keep
models / serializers / views / urls / testssplit as above rather than one mega-file. - Server owns the tenant:
read_only_fieldson the FK, stamped inperform_create. Stamp the audit trail in the same override —perform_createsetscreated_by(andupdated_by) alongside the tenant,perform_updatesetsupdated_by— from the request user, never the client. Newcomers wire the tenant and forget the who. - Tests include the isolation case for every scoped resource — it is the one test reviewers block a PR for missing.
Adapt to your repo
Rename Entreprise/entreprise and the accessor (user.entreprise_id) to your
tenant model. Adjust the resource string and permission class to your RBAC helper's
names. Confirm your project urls.py mounts app routers under a stable prefix
(/api/). Frontend features mirror this on the Next.js side — see nextjs-module.
Gotchas
- Skipping the router basename breaks
reverse()and DRF'sHyperlinkedIdentityField. Model.objects.get(pk=...)inside a view bypasses tenant scoping — always go through the scopedget_queryset()/get_object().- Custom
@actionmethods do not inherit the RBAC check automatically — gate each one. - A migration that adds a
null=Falsetenant FK to a populated table needs a default or a data migration (seemigrations). - Business rows are soft-deleted, not hard-
DELETEd. Overridedestroy()to set a flag (archived_at/is_deleted) instead of removing the row, and exclude flagged rows from the defaultget_queryset()so they drop out of lists and 404 on detail while staying recoverable. A realDELETEloses the audit trail and breaks FKs.
See also
multi-tenancydrf-apirbac-permissionsmigrationswrite-tests
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
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.

