django-language-server
AGENTS.md207 starsChanged yesterdayApache-2.0View on GitHub
Read CONTEXT.md for the domain glossary and canonical terminology. Read ARCHITECTURE.md for the deeper system design, crate boundaries, and request/data flow. Before pushing, run just clippy, just fmt, and just lint. Never use cargo doc --open. Prefer explicit tests over helper proliferation. Use helpers only for substantial fixture setup; avoid one-off assertion wrappers and tiny call-chain helpers. Model after crates/djls-templates/src/lexer.rs: clear input, direct execution, direct assertion/snapshot. Keep tests that exercise tracked queries, invalidation, Project fixtures, or behavior spanning crate public…
We split this AGENTS.md into the rules it gives an agent
14 rules. About 0 are common, 3 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 3
Read CONTEXT.md for the domain glossary and canonical terminology.
- Very specific: line 22
Before pushing, run just clippy, just fmt, and just lint.
- Distinctive: line 25
All tests must pass: If a test fails, it is your responsibility to fix it — even if you didn't cause the failure.
- Distinctive: line 27
Prefer explicit tests over helper proliferation.
- Very specific: line 37
Do not edit text inside cog-generated blocks by hand.
- Very specific: line 56
Run just hawk when changing public APIs, moving code across crates, or cleaning up visibility.
- Very specific: line 59
Use tower-lsp-server, not tower-lsp.
- Very specific: line 60
Use camino::Utf8Path/Utf8PathBuf as canonical path types.
- Very specific: line 61
Treat lib.rs as the external crate API.
- Very specific: line 63
Prefer crate::<owning_module>::...
- Very specific: line 65
Use anyhow::Result in binaries and thiserror in libraries.
- Distinctive: line 66
Prefer comments that explain why.
- Very specific: line 67
Use folder.rs, not folder/mod.rs.
- Very specific: line 70
Use /dex for multi-step work that needs task tracking across sessions.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md 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
Agent Guidelines
Read CONTEXT.md for the domain glossary and canonical terminology. Read ARCHITECTURE.md for the deeper system design, crate boundaries, and request/data flow.
Commands
cargo build -q # Build all crates
cargo test -q # Run Rust tests in the current Python environment
cargo test test_name # Run one test by name
cargo test -p crate_name # Test one crate
just test # Test with default Python and Django versions
just testall # Test all supported Python/Django combinations
just e2e # Run Python LSP end-to-end tests
just clippy # Lint with clippy
just fmt # Format code with nightly rustfmt features
just lint # Run pre-commit hooks
just hawk # Check crate-boundary visibility
just corpus sync # Download corpus from lockfile
just corpus sync -U # Re-resolve corpus and syncBefore pushing, run just clippy, just fmt, and just lint. Never use cargo doc --open.
Testing
All tests must pass. If a test fails, it is your responsibility to fix it — even if you didn't cause the failure. Never dismiss failures as "pre-existing" or "unrelated".
Prefer explicit tests over helper proliferation. Use helpers only for substantial fixture setup; avoid one-off assertion wrappers and tiny call-chain helpers. Model after crates/djls-templates/src/lexer.rs: clear input, direct execution, direct assertion/snapshot.
Keep tests that exercise tracked queries, invalidation, Project fixtures, or behavior spanning crate public APIs in crates/*/tests/ when the behavior is reachable through the crate API. Inline src/ #[cfg(test)] modules should test private algorithms and crate-private boundaries directly with explicit inputs. Reuse an existing shared or production database when the subject requires one; do not define one-off test databases.
Benchmarks
A benchmark name is a stable comparison contract. Never rename, remove, or reshape a benchmark to hide a regression.
When a change slows a benchmark, first check for an accidental regression in the code, inputs, setup, and measured path. Profile the hot path and fix real performance bugs. Some features require more work and may remain slower after that review; keep measuring the operation honestly and record why the cost changed. Rename a benchmark only when it truly measures a different operation, explain that change, and preserve the old comparison when it still represents a useful path.
Generated Content
- Do not edit text inside cog-generated blocks by hand. Update the source of truth, then run
just cogto regenerate the block.
Extraction First
Django template knowledge (which tags and filters exist, their roles, structure, argument syntax, how arguments are consumed, and django. module paths) must be an Extracted Fact: derived from Python source by static extraction in djls-project. This includes Django's own builtins, which are Python source in the bundled crates/djls-project/vendor/django-*.zip. When a fact is missing and visible in a compile function, extend extraction.
When extraction cannot prove a fact, add a Fallback Rule to crates/djls-project/src/templates/tags/fallback.rs. A Fallback Rule targets a Django compile function by canonical identity, not a tag name, names its Extraction Gap, and cites evidence: a bundled Django source path:line, or an extraction snapshot showing what extraction produces today. For Django's own libraries, check the bundled-Django snapshots (cargo test -p djls-project --test it bundled_django, crates/djls-project/tests/it/snapshots/it__bundled_django__*) and the provenance table (crates/djls-semantic/tests/it/snapshots/it__bundled_django_provenance__*); the corpus checks Django out as project code, so corpus__repos__django-* snapshots do not show what production extracts from Django. For third-party libraries, run cargo test -p djls-project --test corpus after just corpus sync. Without that evidence, do not add a Fallback Rule.
djls-semantic, djls-ide, and djls-server key behavior on Tag Roles and extracted facts, never on Django names. The django_knowledge_guard test in djls-testing enforces this for production code; a literal that matches a Django name without being Django knowledge goes in crates/djls-testing/tests/django_knowledge_allowlist.toml with a one-line reason.
Crate Responsibilities
djls-conf: config schema/loading.djls-format: formatter backend adapter boundary.djls-ide: IDE feature behavior and LSP-shaped outputs.djls-project: project model, Python environment discovery, module resolution, template discovery/resolution, derived Django facts, static source recognizers, and Python spec extraction (tag rules, block specs, filter arities, model graph). This is where Django template knowledge comes from.djls-semantic: Django project meaning: template validation, scoping, structure, fusion of extracted tag facts into tag specs, and template-reference relationships.djls-server: LSP/session glue, open document buffers, overlay filesystem adapter. Resolve documents, check file kind, calldjls-ide.djls-source: files, filesystem access/discovery, spans, line indexes, diagnostics primitives.djls-templates: template syntax only.
Run just hawk when changing public APIs, moving code across crates, or cleaning up visibility. It is compile-intensive and may run multiple Cargo analysis passes. Review visibility findings against crate responsibilities before using --fix; run normal lint/test checks afterward for dead-code cleanup.
Code Style
- Use
tower-lsp-server, nottower-lsp; import LSP types viatower_lsp_server::ls_types. - Use
camino::Utf8Path/Utf8PathBufas canonical path types. Convert fromstd::pathonly at API boundaries. - Treat
lib.rsas the external crate API. Internal code should import from the owning module path, not from crate-root re-exports. - Module façade files may re-export their intended boundary API, but avoid re-exporting items through multiple layers unless that layer is a real domain boundary.
- Prefer
crate::<owning_module>::...for internal imports. Usesuper::...only inside local test modules or when reaching private siblings is clearer than exposing a broader module API. - Formatting uses
just fmtbecause.rustfmt.tomlneeds nightly rustfmt. Do not runcargo fmtdirectly. Usejust fmt --checkonly for explicit verification gates. - Use
anyhow::Resultin binaries andthiserrorin libraries. - Prefer comments that explain why; do not write obvious doc comments.
- Use
folder.rs, notfolder/mod.rs.
Task management
Use /dex for multi-step work that needs task tracking across sessions.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 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 repository9 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- dexSkill
- djls-changelogSkill
- djls-domain-conventionsSkill
- djls-resolver-corpusSkill
- djls-ruff-astSkill
- djls-salsaSkill
- djls-testingSkill
- djls-workspace-conventionsSkill
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.

