Skip to content

[Doc] Add CLAUDE.md / AGENTS.md with contribution rules for AI agents#3686

Merged
vmoens merged 1 commit intopytorch:mainfrom
vmoens:doc/agent-contributing-rules
Apr 28, 2026
Merged

[Doc] Add CLAUDE.md / AGENTS.md with contribution rules for AI agents#3686
vmoens merged 1 commit intopytorch:mainfrom
vmoens:doc/agent-contributing-rules

Conversation

@vmoens
Copy link
Copy Markdown
Collaborator

@vmoens vmoens commented Apr 28, 2026

Summary

  • Adds CLAUDE.md documenting TorchRL's house rules for LLM-driven contributions, sitting on top of CONTRIBUTING.md.
  • Adds AGENTS.md as a symlink to CLAUDE.md so Codex and Claude see the same rules and they cannot drift.

The rules cover:

  • Imports: no local imports except for optional deps (gated by _has_<name> = importlib.util.find_spec(...)) or genuine circular imports (try TYPE_CHECKING first); no wildcard imports; from __future__ import annotations at the top of new files.
  • Cross-version compatibility: use torchrl.implement_for (from pyvers) instead of hand-rolled version branching.
  • Logging / timing: use torchrl_logger instead of print; use torchrl.timeit instead of ad-hoc time.time().
  • TensorDict-first APIs and the _AcceptedKeys pattern for new objectives.
  • torch.compile / cudagraphs friendliness (encouraged, not mandatory): prefer torch.where over Python control flow, avoid data-dependent shapes / .item() on hot paths.
  • Tests: every new public class needs tests; extend existing test files rather than creating new ones; new algorithms must run in the sota-implementations CI.
  • Docs: every new public class is referenced in docs/source/reference/*.rst; Sphinx-style docstrings with runnable >>> examples; arXiv refs for paper-based features; no emojis.
  • Tutorials for headline features, structured Sphinx-first with "What you will learn" / "Conclusion" / "Further reading" sections, using # prose comments rather than print(...).
  • Benchmarks for performance-relevant changes.
  • SOTA: new algos ship a Hydra script under sota-implementations/<algo>/ plus a sota-check/ entry.
  • Type hints on new public signatures (documentary, but must be accurate).
  • Deprecation policy: two-release schedule (deprecate in 0.X, default change in 0.X+1, removal in 0.X+2), using DeprecationWarning / FutureWarning with the target version named explicitly in the message.
  • PR labels: canonical [Tag] set documented ([Algorithm] [BE] [BugFix] [CI] [Deprecation] [Doc] [Feature] [Minor] [Performance] [Quality] [Refactor] [Test] [Versioning]).

No squash-commit requirement.

Test plan

  • Render CLAUDE.md on GitHub and confirm the formatting reads well.
  • Confirm AGENTS.md resolves to CLAUDE.md (GitHub renders symlinks as a link to the target).
  • Sanity-check that the rules match current repo conventions (imports, logger, timeit, _AcceptedKeys, implement_for, label set in recent git log).

…I agents

Documents the house rules for LLM-driven contributions: import policy,
implement_for / torchrl.timeit / torchrl_logger usage, TensorDict-first
expectations, the _AcceptedKeys pattern for objectives, compile-friendliness
guidance, test/doc/tutorial/benchmark requirements, the two-release
deprecation schedule, and the canonical PR label set.

AGENTS.md is symlinked to CLAUDE.md so Codex and Claude see the same rules
and they cannot drift.
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 28, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3686

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 2 Awaiting Approval, 2 New Failures, 13 Pending

As of commit 5c6aa62 with merge base e479313 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 28, 2026
@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Apr 28, 2026
@vmoens vmoens merged commit b3a7054 into pytorch:main Apr 28, 2026
127 of 132 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant