Stanford Computer Science course releases strict Model Context Protocol guidelines for agentic code management
Stanford's CS336 course has published its official CLAUDE.md guidelines for AI agents. This developer cheatsheet outlines styling, command executions, and state management rules to prevent agents from breaking project structures. Implement these patterns inside your local workspaces.
Why it matters
You can implement this exact CLAUDE.md structure in your project today to stop Claude Code from generating non-idiomatic code or executing broken shell commands.
TL;DR
- 01Create a 'CLAUDE.md' file in your repository root with explicit Build, Test, and Style guidelines.
- 02List exact shell commands for running tests and linters so agents do not guess or hallucinate.
- 03Define code style preferences clearly (e.g., snake_case, type hints) to ensure consistent codebase contributions.
Defining the Agent's Role
Stanford's CS336 repository introduces a rigorous CLAUDE.md framework to ensure AI agents act as teaching assistants rather than just solution generators. The guidelines emphasize that for courses like CS336, which are implementation-heavy (Python/PyTorch), agents should focus on guidance, debugging, and code review.
Practical Constraints
Agents are explicitly restricted from:
- Completing TODO sections in student assignments.
- Refactoring large code portions into finished solutions.
- Implementing core assignment components like
Triton kernelsortraining loopsdirectly.
Instead, agents are instructed to ask clarifying questions about what the student has tried and point to lecture materials at cs336.stanford.edu.
Handling Errors
When a student faces an error, the agent is expected to explain messages from PyTorch, CUDA, or distributed training tools while encouraging the use of sanity checks and assertions. For instance, when a student struggles with a causal mask, the agent provides specific checks (e.g., verifying mask broadcast shape) rather than giving the fix. This configuration helps maintain the integrity of the educational process while still providing professional-level support through an active dialog.
✓ When to use
- When teaching programming with AI
- To constrain LLM behavior in specific domains