Repository navigation
docs: add AGENTS.md with repo guidelines for LLMs - #912
Conversation
Documents the commands, package layering, per-app API conventions, applet structure, publishing model, database compatibility rules (SQLite/MySQL/PostgreSQL, READ COMMITTED, constraints over locks), and test conventions so that Claude Code sessions start with the repo's architecture and constraints already in context. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The API layer is called from views, tasks, management commands, migrations, and other apps, so it must not use get_object_or_404, Http404, DRF imports, or request parameters. Also correct the permissions note: tagging's API enforces none, but some CBE API functions take a user and raise PermissionDenied themselves. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Note to reviewers: the |
|
Should we call it |
| `openedx_catalog` additionally has an `isolated_apps` import-linter contract | ||
| (`test_utils/isolated_apps_contract.py`): code outside it may import only its `api`, | ||
| `models_api`, `data` and `tests` modules. |
There was a problem hiding this comment.
Should we say that this should be extended to other apps? (not just openedx_catalog)
There was a problem hiding this comment.
Sure. Added a note that we want to work towards this with all our apps. I should move the isolated apps contract elsewhere and have the other apps to use it, but I don't want to yak shave on this right now. I'm mostly just trying to get in something mostly reasonable to help reduce the friction with some CBE reviews.
Ah, good point. I'll do that. |
The guidelines are tool-agnostic, so publish them under the generic AGENTS.md name that other coding agents read. Claude Code reads AGENTS.md natively from v2.1.277 when no CLAUDE.md exists, but a CLAUDE.md or CLAUDE.local.md anywhere up the tree shadows it, and older sessions read only CLAUDE.md. A one-line CLAUDE.md that imports AGENTS.md covers both cases. Co-Authored-By: Claude Fable 5.1 <[email protected]>
I don't want to start enforcing this just yet, as it's outside the scope of this pull request. But a small note to say that we want to work towards this pattern for all apps, and it's not just an openedx_catalog-specific thing.
|
@bradenmacdonald: updated with changes |
| `pylintrc_tweaks` and run `edx_lint write pylintrc`; do not edit the generated files. | ||
| Likewise `constraint-dependencies` in `pyproject.toml` is overwritten by `make upgrade`; | ||
| repo-specific constraints go in `[tool.edx_lint].uv_constraints`. | ||
| - `pii_check` is not in the CI matrix, but every model needs either a `.. no_pii:` (or `.. pii:` |
There was a problem hiding this comment.
(not blocking for this PR:) Is this just an oversight, or why do we not have pii_check in the CI matrix? I've actually been bitten by this before, when the .annotation_safe_list.yml for this repo and the one for openedx-platform got out of sync.
| - Permissions use django-rules, always checked through `user.has_perm(...)` rather than by | ||
| calling a predicate directly, because openedx-platform swaps in org-aware rules via | ||
| `rules.set_perm` and a direct call skips them. Tagging's `api.py` enforces no permissions (its | ||
| views do); some CBE API functions take a `user` and raise Django's `PermissionDenied` | ||
| themselves. A consuming project needs `rules.apps.AutodiscoverRulesConfig` in `INSTALLED_APPS` | ||
| and `rules.permissions.ObjectPermissionBackend` in `AUTHENTICATION_BACKENDS`; without them every | ||
| non-superuser gets 403 with nothing in the logs, and testing as a superuser hides the problem. |
There was a problem hiding this comment.
(not a blocker:) Just noting that OEP 66 recommends bridgekeeper over django-rules, although bridgekeeper hasn't been updated in the last 5 years. I guess either one works.
|
Thanks for writing this up, Dave. Apologies for my slow response here. I read through it and it looked fine to me, so I don't have corrections. Since Unicon works from our own Claude Code config for this repo, I asked Claude to diff that config against AGENTS.md and list rules we rely on that AGENTS.md doesn't state yet. The list below is that output, lightly edited. Feel free to take or leave any of it. Never silence a check to make it pass. Comments and docstrings. Comment why, not what, and no change narration ("updated X", "as requested"). Public functions, classes, and models get RST docstrings that describe the contract rather than the implementation. Treat a stale comment as a bug and fix or delete it in the same change.
Smallest correct change. No unrequested abstractions, flexibility, or error handling for impossible cases. Don't refactor or reformat code the task doesn't touch, and don't extract shared code until three callers need it. This is generic agent hygiene, but in our experience it's the biggest single source of review churn on agent-written PRs. Consumers and companion changes. A change here often does nothing until openedx-platform picks up a new release, and migrations actually run there, not in this repo. The PR should name the companion platform change when one is needed. The New model fields surface through generic code. An admin registration without an explicit |
Summary
Adds a
CLAUDE.mdat the repo root so that Claude Code sessions start with the repo's commands, architecture, and constraints already in context, instead of rediscovering them each time.What it covers:
make upgrade, and the edx-lint-generated files that must not be hand-edited.mainturns the commit type into a PyPI release.select_for_update()to catch races, and the existing per-vendor patterns (collation helpers, upsert branching, InnoDB index key limits, NULL and uniqueness, ordering).api.py/models_api.py/data.pycontract, how applets work insideopenedx_contentandopenedx_learningand what to touch when adding one, thebackcompat/shells, the publishing model (learning packages, entities and versions, drafts, containers, change logs and side effects), extensibility via 1:1 models, django-rules setup pitfalls, and the two coexisting test styles.Everything was checked against the config files, ADRs, and READMEs rather than written from memory, and the documented commands were run to confirm they behave as described.
Notes
make pii_checkcurrently fails onmainbecauseopenedx_content.Draftandopenedx_content.PublishableEntityVersionare annotated inline and listed in.annotation_safe_list.yml. That check isn't in the CI matrix, so CI stays green. Not addressed here; just noting it since the doc describes the annotation rule.db_collationsdicts inopenedx_django_lib.fieldshave nopostgresqlentry, so "case-insensitive" fields fall back to PostgreSQL's default case-sensitive collation. The doc records that as a known gap rather than papering over it.🤖 Generated with Claude Code