pigweed / pw_ide
AGENTS.md561 starsChanged 16 days agoApache-2.0View on GitHub
This document provides foundational principles and technical requirements for AI agents contributing to pw_ide. This document extends the top-level AGENTS.md guidance with additional instructions more specific to the files contained under this subdirectory.
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 31,439 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 repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- pw_ghish/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- BluetoothSkill
- Code ReviewSkill
- crankSkill
- docsSkill
- freshenSkill
- ghishSkill
- manual-cli-testSkill
- oncallSkill
- pw_async2Skill
- Pigweed Kernel TestingSkill
- C++ Pigweed RPC ServicesSkill
- respondSkill
- reviewSkill
- run-presubmit-checksSkill
- saleae-analyzerSkill
- Use Pigweed Toolchain ToolsSkill
- Multi-Agent Worktree & Bazel Cache ManagementSkill
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Pure Functions: Prefer extracting logic into pure functions with no side effects to simplify reasoning and testing.
- Distinctive: line 21
No Unverified Changes: All new features, refactors, and bug fixes must include automated tests.
- Very specific: line 26
Python: Use unittest with pyfakefs for robust filesystem mocking.
- Very specific: line 27
Starlark: Use unittest.make for all Starlark logic verification.
- Very specific: line 32
Use
PathObjects: Use pathlib.Path exclusively for path operations. - Very specific: line 33
Avoid os.path and string-based path manipulation.
- Very specific: line 34
Maintain Type Integrity: Keep paths as Path objects throughout the application logic.
- Distinctive: line 37
Portability: Ensure paths in generated project files are relative to the workspace root, not absolute.
- Distinctive: line 56
$O(1)$ Lookups: Use dictionaries for mapping and filtering to avoid nested loops ($O(M \times N)$).
- Very specific: line 60
Explicit Copies: Use dict() to create shallow copies of dictionaries to prevent shared state bugs.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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
Pigweed IDE (pw_ide) Engineering Guidelines
This document provides foundational principles and technical requirements for AI
agents contributing to pw_ide. This document extends the top-level AGENTS.md
guidance with additional instructions more specific to the files contained under
this subdirectory.
Core Principles
1. Single Responsibility & Conciseness
- Decompose Logic: Each function, class, or Bazel rule must have one clear responsibility. Decompose complex logic into small, reusable, and focused helper functions.
- Explicit over Clever: Prioritize readability and explicit intent over "magic" behavior. Use descriptive naming that explains what data represents, rather than its type.
- Pure Functions: Prefer extracting logic into pure functions with no side effects to simplify reasoning and testing.
2. Mandatory & Focused Testing
- No Unverified Changes: All new features, refactors, and bug fixes must include automated tests.
- Granular Tests: Each test case should verify a single, specific behavior. Use descriptive names that clearly state the test's intent.
- Tools:
- Python: Use
unittestwithpyfakefsfor robust filesystem mocking. - Starlark: Use
unittest.makefor all Starlark logic verification.
- Python: Use
Python Guidelines
1. Path Manipulation with pathlib
- Use
PathObjects: Usepathlib.Pathexclusively for path operations. Avoidos.pathand string-based path manipulation. - Maintain Type Integrity: Keep paths as
Pathobjects throughout the application logic. Convert to strings only at serialization boundaries or when required by external APIs. - Portability: Ensure paths in generated project files are relative to the workspace root, not absolute.
2. Pattern Matching with re
- Prefer Regex for Complexity: For all but the simplest string checks, use
the
repackage. Regular expressions yield faster and more concise code for complex pattern matching.
3. Error Handling
- Exceptions Over Return Codes: Raise descriptive exceptions to handle
errors. Avoid returning
Noneor error codes, which clutter the "happy path" and are easily ignored.
Bazel & Starlark Guidelines
1. Performance & Efficiency
- Minimize Depset Conversions: Converting a
depsetto a list (via.to_list()) is an $O(N)$ operation. Perform this conversion exactly once if needed, and never inside a loop. - $O(1)$ Lookups: Use dictionaries for mapping and filtering to avoid nested loops ($O(M \times N)$).
2. Safety & Correctness
- Explicit Copies: Use
dict()to create shallow copies of dictionaries to prevent shared state bugs. - No Recursion: Starlark does not support recursion; use iterative stacks or queues for graph traversal.
- Explicit Aspect Traversal: Be specific in
attr_aspectswhen writing aspects; avoid the["*"]wildcard to prevent issues with internal Bazel dependencies.
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.

