r3bl-open-core
AGENTS.md485 starsChanged 2 months agoApache-2.0View on GitHub
To prevent catastrophic system failures, all AI agents (Gemini, Claude, etc.) MUST adhere to these strict guardrails. These mandates take absolute precedence over any "YOLO" mode or perceived "fixes." Recursive operations (chown -R, chmod -R, rm -rf) are STRICTLY PROHIBITED on the following top-level system directories and their contents: - Root Ownership: System directories and binaries MUST remain owned by root. The agent must NEVER suggest or execute a change of ownership for system-managed paths to a non-root user. -…
- Deletes or force-pushes
- Installs packages
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 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 repository29 other files it gives its agents.
- .agents/AGENTS.mdAGENTS.md
- build-infra/AGENTS.mdAGENTS.md
- rust-analyzer-mcp-server/AGENTS.mdAGENTS.md
- task/AGENTS.mdAGENTS.md
- analyze-log-filesSkill
- analyze-performanceSkill
- audit-taskSkill
- batch-refactor-with-sub-agentsSkill
- check-bounds-safetySkill
- check-code-qualitySkill
- check-test-coverageSkill
- code-reviewSkill
- concurrency-safetySkill
- create-commit-messageSkill
- create-prSkill
- design-philosophySkill
- fast-string-allocationsSkill
- fix-issueSkill
- merge-prSkill
- organize-modulesSkill
- organize-testsSkill
- release-crateSkill
- remove-crate-prefixSkill
- review-prSkill
- run-clippySkill
- safe-renamingSkill
- test-cross-platformSkill
- write-documentationSkill
- write-structured-tracingSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
65 rules. About 0 are common, 19 are distinctive, and 46 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
46
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Privilege Escalation: Do not modify the setuid or setgid bits of any system binary (e.g., sudo, pkexec, mount) unless specifically …
- Very specific: line 33
MUST use absolute paths. The use of wildcards (*) or relative paths (.) with sudo chown/chmod/rm is forbidden.
- Very specific: line 35
Verification First: Before suggesting a permissions fix, the agent must first verify the current state using ls -ld or stat.
- Distinctive: line 43
Ask for clarification immediately on important choices or ambiguities.
- Distinctive: line 57
Follow this "slow and steady" workflow for all non-trivial changes:
- Distinctive: line 62
Manual Review: Wait for the user to manually review and explicitly approve the task file before starting implementation.
- Distinctive: line 81
Frequent Review Points: Do not perform more than 3-5 consecutive file modifications without pausing to summarize progress and request user …
- Distinctive: line 83
Milestone Stability: Stop and ask for a review as soon as you achieve any stable milestone (e.g., code compiles after a refactor, a …
- Very specific: line 86
Validation before Review: Always run ./check.fish --check or cargo check locally BEFORE asking the user for a review.
- Very specific: line 88
Attention Signal: When stopping for a mandatory review point, run fish -c "beep" to alert the user.
- Very specific: line 96
Review Workflow: When the user prompts for a manual review at the end of a task/phase/sub-phase:
- Very specific: line 98
Option A (Interactive Chat Review): If the user triggers /code-review or asks for an interactive chunk-by-chunk review, follow the …
- Distinctive: line 103
Ask the user: "choose your ide: 1: code, 2: antigravity-ide, 3: codium, 4: code-insiders, 5: codium-insiders, if you press enter we will …
- Distinctive: line 107
Ask the user to manually review it.
- Very specific: line 113
Post-Edit Rustdoc Verification: After any file modification, especially when using write_file, you MUST verify that you have NOT clobbered …
- Distinctive: line 117
Human-in-the-Loop: When in doubt, or when a task involves global renames, stop and confirm the plan for the NEXT 3 files before touching …
- Distinctive: line 119
No
git checkoutfor mistakes: If a mistake is made in a file during a refactor or edit, do NOT run git checkout to revert it. - Very specific: line 122
Git Diff Audit Before Review: Before asking the user for review or declaring a file edit complete, you MUST run git diff <file_path> (or …
- Very specific: line 160
Native Tooling: All code refactoring and modifications MUST be performed file-by-file using native file-editing tools (replace_file_content …
- Very specific: line 169
D. Safe Numeric Casting (No
as): Never use raw primitive as casts (e.g., value as u8). - Very specific: line 185
Look inside the .agents/ directory.
- Distinctive: line 186
Read the markdown instructions inside that folder.
- Distinctive: line 200
Deep investigation: When mapping unfamiliar layers, proactively use multiple search and read calls in a single turn.
- Very specific: line 210
All skills, agents, and slash commands are in the .agents/ directory (not .claude/).
- Very specific: line 211
When loading a skill, agent, or command, look in .agents/skills/, .agents/agents/, and .agents/commands/ respectively.
- Distinctive: line 229
When working on a specific crate, always check for a local AGENTS.md file in that crate's directory for additional workflow requirements.
- Distinctive: line 281
organize-tests: - Test directory taxonomy (why a test is isolated), PTY conventions (Run with section, deadlock prevention), zero …
- Distinctive: line 313
review-pr: - Create a structured integration and review plan for a Pull Request.
- Very specific: line 339
Rule: When adding a new skill to .agents/skills/, you MUST add a corresponding slash command entry for that new skill in the table below.
- Very specific: line 377
Always use
check.fish: instead of running cargo commands directly. - Very specific: line 416
When writing or modifying rustdoc comments in code, task files, or standalone .md files,
- Very specific: line 419
Intra-doc links: Prefer crate:: paths (shorter).
- Very specific: line 423
Human-readable constants: Use binary for bitmasks (0b0110_0000), byte literals for printable chars (b'['), decimal for non-printables (27).
- Very specific: line 430
Sidebar headings: Only # and ## headings appear in the rustdoc sidebar navigation.
- Very specific: line 437
NOT use hyphens (-) to connect clauses or sentences in documentation: write separate sentences or use colons, semicolons, commas, or …
- Very specific: line 440
No
$or LaTeX Math Delimiters (Global Rule): Do NOT use $ or $$ or \(...\) LaTeX math delimiters in doc comments, task .md files, or chat … - Very specific: line 445
Cross-Platform Doctests for Platform-Specific APIs: When writing doctests that reference platform-specific types (such as Linux-only …
- Very specific: line 448
Instead, use the # #[cfg(not(target_os = "linux"))] # fn main() {} and # #[cfg(target_os = "linux")] # mod linux_only { ...
- Very specific: line 453
Don't wait for check-code-quality to catch issues - write docs correctly the first time.
- Distinctive: line 457
When designing Rust types in this codebase:
- Very specific: line 459
No-Argument Constructors: If a type requires no arguments for default construction, derive or implement Default (#[derive(Default)] or impl …
- Very specific: line 460
Parameterized Constructors: If a constructor requires arguments (e.g., with_capacity(capacity: usize) or new(arg: Type)), use explicit …
- Very specific: line 464
When designing mutator methods taking &mut self that can fail due to invalid indices or out-of-bounds conditions:
- Very specific: line 478
Do NOT write absolute inline paths like crate::Type or crate::Size inside function signatures or bodies.
- Very specific: line 500
Do NOT use #[macro_use] on module declarations.
- Very specific: line 506
When working with platform-specific code (#[cfg(unix)], #[cfg(not(unix))]), verify Windows compatibility.
- Very specific: line 519
Use this after modifying DirectToAnsi input handling or other Unix-specific code.
- Very specific: line 530
Do NOT use .and_then() for chaining Option or Result operations in code.
- Very specific: line 557
Do NOT use standard std::collections::HashMap or std::collections::HashSet in this codebase.
- Very specific: line 562
Instead, always import and use rustc_hash::FxHashMap and rustc_hash::FxHashSet (from the rustc-hash = "2.1.0" crate).
- Very specific: line 606
No Destructive Resets: NEVER use git reset HEAD~n, git reset --hard, or git clean unless explicitly and specifically commanded to do so by …
- Distinctive: line 609
No Clobbering Existing Edits: NEVER use git checkout or git restore to overwrite existing files in the working tree unless explicitly and …
- Very specific: line 612
Surgical Unstaging: When asked to unstage specific files, ALWAYS use targeted commands like git restore --staged <file>.
- Very specific: line 618
Never use git stash / git stash pop to test against clean state - it destroys the staging area (index).
- Very specific: line 621
Use git mv instead of mv when moving or renaming files to preserve move history in git.
- Distinctive: line 623
Never commit unless explicitly asked
- Distinctive: line 624
When you do make commits, do not add an attribution to yourself in the commit message.
- Distinctive: line 625
Do not add the following trailing lines (or similar) in a commit message:
- Very specific: line 652
When creating or formatting a commit message, you MUST invoke and follow the create-commit-message skill.
- Very specific: line 664
Always run prettier --write <file> on any task/*.md files after creating or updating them.
- Very specific: line 693
When executing large-scale, tree-wide refactoring tasks (such as mass renaming variables, fields, or types across many files), agents MUST …
- Very specific: line 697
Use Built-in Tools First: Always attempt to use the built-in, precise file modification tools (multi_replace_file_content or …
- Very specific: line 703
Custom Rust Script with
--dry-run: Create a disposable Rust (rustc) script with a mandatory --dry-run CLI argument and strict word … - Very specific: line 706
Staging Execution & Verification: Run --dry-run on ~/Downloads/rename-staging/, apply the changes there, and run the full test suite (cargo …
- Very specific: line 709
Apply to Live Repo: IF AND ONLY IF all tests pass 100% in ~/Downloads/rename-staging/, remove the staging directory and run the refactoring …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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 Instructions for r3bl-open-core
AI Agent Security & System Integrity Mandates
To prevent catastrophic system failures, all AI agents (Gemini, Claude, etc.) MUST adhere to these strict guardrails. These mandates take absolute precedence over any "YOLO" mode or perceived "fixes."
1. Critical Directory Protection
Recursive operations (chown -R, chmod -R, rm -rf) are STRICTLY PROHIBITED on the
following top-level system directories and their contents:
/(Root)/usr(System binaries and libraries)/etc(System configuration)/bin,/sbin,/lib,/lib64(Essential system paths)/boot(Bootloader and kernels)/var(Variable data, including system logs and databases)
2. Ownership & Integrity
- Root Ownership: System directories and binaries MUST remain owned by
root. The agent must NEVER suggest or execute a change of ownership for system-managed paths to a non-root user. - Privilege Escalation: Do not modify the
setuidorsetgidbits of any system binary (e.g.,sudo,pkexec,mount) unless specifically instructed by the user to fix a verified corruption.
3. Execution Safety
- Explicit Paths Only: All
sudocommands involving recursive changes or deletions MUST use absolute paths. The use of wildcards (*) or relative paths (.) withsudo chown/chmod/rmis forbidden. - Verification First: Before suggesting a permissions fix, the agent must first verify
the current state using
ls -ldorstat. - Destructive Warning: Any command that modifies system-wide permissions or ownership must be explicitly flagged to the user with a explanation of the risks, even in YOLO mode.
Ask for clarification immediately on important choices or ambiguities. Take your time with changes: slow, steady, and careful work beats fast and careless.
Standard Workflow (Alignment -> Plan -> Execute)
To ensure safety and alignment, always start by clarifying the scope of work. Ask the user: "Are we starting:
- a new task,
- continuing an existing task, or
- doing one-off work? (Please respond with 1, 2, or 3)"
1. New Task (Plan -> Task File -> Execute)
Follow this "slow and steady" workflow for all non-trivial changes:
- In-Chat Planning: Research the problem and present a comprehensive plan in chat for refinement. Use code examples and specifics.
- Task File Creation: Once approved, formalize it via
/r3bl-task create <name>. - Manual Review: Wait for the user to manually review and explicitly approve the task file before starting implementation.
- Iterative Implementation: Implement step-by-step, using
/r3bl-task update <name>.
2. Existing Task
- Load Task: Identify the active task in
task/and use/r3bl-task load <name>. - Resume: Resume work from the next unchecked step after confirming with the user.
3. One-off Work
- For simple, isolated changes that do not require formal planning or task tracking, proceed directly to research and implementation.
Progress & Review Guardrails (Anti-Hallucination)
To prevent large-scale destructive errors, "hallucinations," or accidental deletions during complex or long-running tasks, you MUST follow these loop-in-the-user rules:
- Frequent Review Points: Do not perform more than 3-5 consecutive file modifications without pausing to summarize progress and request user verification.
- Milestone Stability: Stop and ask for a review as soon as you achieve any stable milestone (e.g., code compiles after a refactor, a sub-module is renamed, or a complex regex operation is completed).
- Validation before Review: Always run
./check.fish --checkorcargo checklocally BEFORE asking the user for a review. Never present "broken" progress. - Attention Signal: When stopping for a mandatory review point, run
fish -c "beep"to alert the user. - Mandatory Manual Review: A task, phase, or sub-phase is not complete until the user
has performed a manual review. This is the final step in the verification lifecycle. Do
not mark a task as done in the task file until this review is successfully completed.
- Automatic Requirement: You MUST automatically add a "Mandatory manual review" step with a checkbox list of all modified files to the end of every task, phase, and sub-phase you create or update.
- Review Workflow: When the user prompts for a manual review at the end of a
task/phase/sub-phase:
- Option A (Interactive Chat Review): If the user triggers
/code-reviewor asks for an interactive chunk-by-chunk review, follow thecode-reviewskill to audit test coverage (check-test-coverage), present diffs one chunk at a time, and wait for approval. - Option B (IDE Review):
- Ask the user: "choose your ide: 1: code, 2: antigravity-ide, 3: codium, 4: code-insiders, 5: codium-insiders, if you press enter we will default to 1". (Note: if the user types "agy-ide" or similar, map it to "antigravity-ide").
- Then use
<IDE> <file_path>to open the first file with a checkbox. - Ask the user to manually review it.
- Once the user confirms ("good" or similar), check the box in the task file.
- Move to the next file and repeat until all checkboxes are checked.
- Option A (Interactive Chat Review): If the user triggers
- Strict Documentation Preservation: Documentation is as critical as code. Any surgical edit that touches doc comments must be byte-perfect in its preservation of surrounding text.
- Post-Edit Rustdoc Verification: After any file modification, especially when using
write_file, you MUST verify that you have NOT clobbered pre-existing and valid rustdoc comments, diagrams, or module-level documentation. This is a high-priority check to maintain documentation integrity. - Human-in-the-Loop: When in doubt, or when a task involves global renames, stop and confirm the plan for the NEXT 3 files before touching them.
- No
git checkoutfor mistakes: If a mistake is made in a file during a refactor or edit, do NOT rungit checkoutto revert it. Instead, systematically fix the mistake using the built-in native file-editing tools accurately, deliberately, and slowly. - Git Diff Audit Before Review: Before asking the user for review or declaring a file
edit complete, you MUST run
git diff <file_path>(orgit diff) on all modified files. Audit the diff line-by-line to verify that changes are strictly surgical and contain zero unintended collateral modifications (such as altered doctests, lost doc comments, or modified function signatures).
Design Philosophy
Prioritize low cognitive load, progressive disclosure, and type-safe design. Make illegal
states unrepresentable. See design-philosophy skill for principles and patterns.
Tooling & Capabilities
A. Semantic Rust Tools (AST-Aware MCP): Priority #1. When connected to the Rust MCP
server named rust-analyzer (running the rust-analyzer-mcp-server binary), aggressively use its
tools for code navigation (rust_analyzer_definition, rust_analyzer_references,
rust_analyzer_hover, rust_analyzer_symbols), quick-fixes
(rust_analyzer_code_actions), and diagnostics (rust_analyzer_diagnostics). These
AST-level operations are the safest way to inspect and modify code.
B. Native File Replacements: Priority #2. For structural changes that fall outside the
MCP's capabilities, use native file-editing tools like multi_replace_file_content.
Combine these with semantic tools (like find_references) to ensure you are modifying the
correct call sites. Do NOT write Python scripts.
C. Bulk Code Modifications:
- Scripts of ANY Kind are STRICTLY PROHIBITED: You are forbidden from using scripts
of any kind (whether shell-based like
perl,sed,awk,python,bash,fish, or custom/disposable Rust scripts compiled viarustc) to perform file content modifications or bulk find-and-replaces.- NEVER use
sedfor blind type/variable renaming (it causes massive collateral damage to unstaged code and unrelated logic). - NEVER use
awk(e.g.,awk '!seen[$0]++') for "cleaning up" files or deduplicating imports; it will destroy the file by removing all structural duplicate lines like}or empty lines. - NEVER use disposable Rust or Python scripts for bulk refactoring; subtle grammar and lexical edge cases (comments, doc tests, strings, shadowing) inevitably cause bugs.
- NEVER use
- Native Tooling: All code refactoring and modifications MUST be performed file-by-file
using native file-editing tools (
replace_file_contentandmulti_replace_file_content) combined with AST-level semantic tools (rust-analyzer). - Optional Disposable Staging: For extensive or multi-file changes, it is permissible
to create a disposable copy (e.g., via BTRFS reflink
cp --reflink=auto) where manual changes are made and everything is checked for correctness (./check.fish --check,./check.fish --test,./check.fish --clippy,./check.fish --quick-doc) before the changes are finalized in the real codebase.
D. Safe Numeric Casting (No as): Never use raw primitive as casts (e.g.,
value as u8). Instead, use the type-safe casting traits defined in
tui/src/core/common/primitive_casting.rs (e.g., WideningCastTo...,
NarrowingCastTo...). If a raw as cast is absolutely unavoidable (e.g., in const
contexts or dealing with FFI), you MUST annotate it perfectly with both a comment and an
allow attribute:
// XMARK: Intentional numeric casting using as.
#[allow(clippy::as_conversions)]E. Local Workflows (.agents/): For repo-specific workflows (clippy, formatting, log
analysis), capabilities are defined in the .agents/ directory. When a task matches a
skill, agent, or command:
- Look inside the
.agents/directory. - Read the markdown instructions inside that folder.
- Execute the underlying shell/scripts exactly as instructed.
Context Guardrail
You do not have the full codebase in memory. Actively use search and file-reading tools to gather local context. If a request requires system-wide knowledge, global refactoring, or sweeping architectural changes, DO NOT GUESS. Stop and ask the user to provide broader context.
Research Efficiency
- Batch tool calls: Execute research and file-reading tools in parallel to build context rapidly.
- Deep investigation: When mapping unfamiliar layers, proactively use multiple search and read calls in a single turn.
- Autonomous progress: In autonomous mode, do not stop for minor clarifications. Complete research and propose a high-signal plan in chat before pausing. Always follow the Standard Workflow and do not skip the alignment or approval steps.
- Milestone delivery: Aim for one high-signal turn (e.g., a complete research summary or initial chat plan) rather than many low-signal turns.
Skills, Agents & Commands Location
All skills, agents, and slash commands are in the .agents/ directory (not .claude/).
When loading a skill, agent, or command, look in .agents/skills/, .agents/agents/, and
.agents/commands/ respectively.
Crate-Specific Instructions
Some crates have additional instructions in their own AGENTS.md files:
- build-infra/: Provides CLI tools (binaries). After making code changes, you MUST
run
cargo install --path build-infra --forceto update the installed binaries in~/.cargo/bin. Seebuild-infra/AGENTS.mdfor details. - rust-analyzer-mcp-server/: Provides the
rust-analyzer-mcp-serverMCP binary. After making code changes, you MUST runcargo install --path rust-analyzer-mcp-server --forceto update the installed binary in~/.cargo/bin. Seerust-analyzer-mcp-server/AGENTS.mdfor details. - tui/: Main crate (
r3bl_tui). For test directory taxonomy, PTY integration test conventions, and subprocess isolation patterns, use theorganize-testsskill.
When working on a specific crate, always check for a local AGENTS.md file in that
crate's directory for additional workflow requirements.
Available Skills
This project uses skills to organize coding patterns and workflows. All skills are in
.agents/skills/. When loading a skill, also check for and read any supporting .md
files in that skill's directory (e.g., patterns.md, reference.md, examples.md).
Design
- design-philosophy - Core principles: cognitive load, progressive disclosure, type
safety, abstraction worth. Use when designing APIs, modules, or data structures.
- Supporting file:
patterns.md(good/bad examples and quick reference)
- Supporting file:
Code Quality & Style
- check-code-quality - Comprehensive quality checklist (check -> build -> docs ->
clippy -> tests). Use after completing code changes and before creating commits.
- Supporting file:
reference.md(detailed cargo command reference)
- Supporting file:
- check-test-coverage - Audit and verify branch-targeted test coverage for a specific file or module, ensuring all custom logic paths and error branches are covered while strictly eliminating dependency test bloat.
- Supporting file:
examples.md(audit patterns and good vs bad coverage examples)
- Supporting file:
- run-clippy - Clippy linting, comment punctuation, cargo fmt. Use after code changes
and before creating commits.
- Supporting file:
patterns.md(code style patterns and examples)
- Supporting file:
- remove-crate-prefix - Clean up generated code by removing unnecessary
crate::<T>prefixes and instead importinguse crate::<T>at the top of the file. Use this to comply with the "Clean Imports over Inline Absolute Paths" mandatory rule. - code-review - Interactive chunk-by-chunk in-chat code review with explicit approval
steps. Use when the user requests an interactive code review or runs
/code-review. - test-cross-platform - Synchronize repository to the fleet (macOS, Windows) and run the full test suite across all platforms concurrently. Use via
/test-cross-platform.
Documentation
- write-documentation - Consolidated documentation skill covering structure (inverted
pyramid), intra-doc links, constant conventions, and formatting. Use proactively when
writing code with rustdoc comments, or retroactively via
/fix-intradoc-links,/fix-comments,/fix-md-tables.- Supporting files:
link-patterns.md,constant-conventions.md,examples.md,rustdoc-formatting.md
- Supporting files:
Architecture & Patterns
- organize-modules - Private modules with public re-exports (barrel export pattern),
conditional visibility for docs/tests. Use when creating or organizing modules.
- Supporting file:
examples.md(6 complete module organization examples)
- Supporting file:
- organize-tests - Test directory taxonomy (why a test is isolated), PTY conventions
(Run with section, deadlock prevention), zero test-bloat directive (test our code, not
dependencies), and isolated process orchestration. Use when adding or refactoring tests.
- Supporting files:
taxonomy.md(directory guide),pty-conventions.md(PTY rules),examples.md(macro templates)
- Supporting files:
- check-bounds-safety - Type-safe Index/Length patterns for arrays, cursors,
viewports, and terminal cursor movement. Includes
TermRowDelta/TermColDeltafor safe relative cursor movements that prevent CSI zero bugs. Use when working with bounds-sensitive code.- Supporting file:
decision-trees.md(visual decision trees and flowcharts)
- Supporting file:
- concurrency-safety - Thread safety, Chain of Custody, Loud Lock Releases, and
AtomicU8Ext patterns. Use when working with threads, locks, or atomics.
- Supporting file:
patterns.md(good/bad examples of lock management)
- Supporting file:
- fast-string-allocations - Zero-allocation string building strategies. Use when formatting strings, generating ANSI codes, or writing hot loops to avoid heap allocations and Formatter overhead.
Performance
- analyze-performance - Flamegraph-based performance regression detection. Use when
optimizing or investigating performance.
- Supporting file:
baseline-management.md(when and how to update baselines)
- Supporting file:
Release
- release-crate - Full crate release workflow: version bump, changelog, standalone release
notes in
docs/release-notes/, publish to crates.io, git tag, GitHub release. Use when releasing a new version of any workspace crate. - review-pr - Create a structured integration and review plan for a Pull Request. Use when the user wants to systematically integrate a community PR.
- create-pr - Push local changes and create a GitHub Pull Request. Use when you have
local changes that need a PR but didn't start with
/fix-issue. - merge-pr - Workflow for pushing a completed task branch, creating a Pull Request, and merging it to main via rebase.
Log Analysis
- analyze-log-files - Strip ANSI escape sequences from log files before analysis. Use when asked to process, read, or analyze log files that may contain terminal escape codes.
Available Agents (.agents/agents/)
| Agent | Purpose |
| test-runner | Expert in running tests and fixing failures |
| clippy-runner | Expert in linting and fixing style issues |
| code-formatter | Expert in bulk code formatting |
| perf-checker | Expert in performance regression analysis |
Slash Commands
Rule: When adding a new skill to .agents/skills/, you MUST add a corresponding slash
command entry for that new skill in the table below. This ensures the command is available
via autocomplete in the Antigravity CLI.
| Command | Skill |
/analyze-logs | analyze-log-files |
/audit-task | audit-task |
/check-regression | analyze-performance |
/batch-refactor | batch-refactor-with-sub-agents |
/check-bounds-safety | check-bounds-safety |
/check | check-code-quality |
/check-test-coverage | check-test-coverage |
/code-review | code-review |
/concurrency-safety | concurrency-safety |
/create-commit-message | create-commit-message |
/create-pr | create-pr |
/design-philosophy | design-philosophy |
/fast-string-allocations | fast-string-allocations |
/fix-issue | fix-issue |
/merge-pr | merge-pr |
/organize-modules | organize-modules |
/organize-tests | organize-tests |
/release | release-crate |
/remove-crate-prefix | remove-crate-prefix |
/review-pr | review-pr |
/test-cross-platform | test-cross-platform |
/clippy | run-clippy |
/docs | write-documentation |
/fix-intradoc-links | write-documentation (focused on links) |
/fix-comments | write-documentation (constant conventions) |
/fix-md-tables | write-documentation (table formatting) |
/write-structured-tracing | write-structured-tracing |
/r3bl-task | Task management (see below) |
/boxes | Unicode box-drawing character set |
Running Checks
Always use check.fish instead of running cargo commands directly. check.fish
provides ICE recovery, stale artifact cleanup, config change detection, toolchain
validation, and tmpfs/ionice optimizations, all of which are lost with direct cargo calls.
| Command | What it runs |
./check.fish --check | cargo check (fast typecheck) |
./check.fish --build | cargo build (compile production) |
./check.fish --clippy | cargo clippy --all-targets (linting) |
./check.fish --fmt | cargo fmt + cargo rustdoc-fmt on git-changed files |
./check.fish --test | cargo test + doctests |
./check.fish --doc | cargo doc --workspace (full, with dep-doc caching) |
./check.fish --quick-doc | cargo doc --workspace --no-deps (fastest, no staging/sync) |
./check.fish --full | All of the above + Windows cross-compilation check + lychee link rot check |
Commands with no check.fish equivalent (run directly):
cargo rustdoc-fmt: format rustdoc commentscargo clippy --all-targets --fix --allow-dirty: auto-fix lintscargo fmt --all: format code
Non-Blocking Verification via Subagents
Long-running verification commands (such as ./check.fish --test, ./check.fish --doc,
./check.fish --quick-doc, and ./check.fish --full) can take 1 to 2+ minutes. To prevent
blocking the active conversation loop:
- Fast Checks: Lightweight commands like
./check.fish --checkand./check.fish --fmttake only a few seconds and may run directly. - Long-Running Checks: Delegate time-consuming checks to a background subagent (e.g.,
using
invoke_subagentwithTypeName: "self"). - Unblocked Collaboration: While the subagent verifies build, test, or documentation status in the background, the primary agent remains interactive to discuss code, perform reviews, and plan next steps.
Rust Code Guidelines
Writing Documentation & Markdown
When writing or modifying rustdoc comments in code, task files, or standalone .md files,
proactively apply these conventions (all documented in write-documentation skill):
- Intra-doc links: Prefer
crate::paths (shorter). Usesuper::whencrate::paths get too long and symbols are co-located. Reference-style links at bottom of doc blocks. Seelink-patterns.mdfor patterns. - Human-readable constants: Use binary for bitmasks (
0b0110_0000), byte literals for printable chars (b'['), decimal for non-printables (27). Show hex in comments for cross-reference. Seeconstant-conventions.md. - Inverted pyramid: High-level concepts at module/trait level, simple syntax examples
at method level. See
examples.md. - Sidebar headings: Only
#and##headings appear in the rustdoc sidebar navigation. Use**bold**text instead of###for sub-sections within doc comments. - No connecting dashes, en dashes, or em dashes (Global Rule): The ASCII hyphen /
hyphen-minus (
-,U+002D) is the ONLY dash character permitted anywhere in the codebase (including.mdtask/plan files, rustdoc, and chat responses). Non-ASCII en dashes (–) and em dashes (—, endash/emdash) are strictly forbidden. Furthermore, do NOT use hyphens (-) to connect clauses or sentences in documentation: write separate sentences or use colons, semicolons, commas, or parentheses instead. - No
$or LaTeX Math Delimiters (Global Rule): Do NOT use$or$$or\(...\)LaTeX math delimiters in doc comments, task.mdfiles, or chat responses. They do not render correctly in standard markdown viewers. Use standard Markdown text, backticks (e.g.,[start, start+len)), or code blocks instead. - Cross-Platform Doctests for Platform-Specific APIs: When writing doctests that
reference platform-specific types (such as Linux-only
DirectToAnsiInputDeviceorMioPollWorker), do NOT useignoreand do NOT downgrade them to noisy generic mocks. Instead, use the# #[cfg(not(target_os = "linux"))] # fn main() {}and# #[cfg(target_os = "linux")] # mod linux_only { ... }pattern documented in thewrite-documentationskill. This keeps rendered docs clean, validates real types on Linux, and compiles safely on macOS and Windows.
Don't wait for check-code-quality to catch issues - write docs correctly the first time.
Constructor Conventions: Default over No-Arg new()
When designing Rust types in this codebase:
- No-Argument Constructors: If a type requires no arguments for default construction, derive or implement
Default(#[derive(Default)]orimpl Default for MyType) and do NOT create a redundantpub fn new() -> Selfmethod. Callers instantiate it viaMyType::default()orDefault::default(). - Parameterized Constructors: If a constructor requires arguments (e.g.,
with_capacity(capacity: usize)ornew(arg: Type)), use explicit constructor methods with parameters.
Mutator Return Conventions: Avoid Boolean Blindness (Option<T> / Option<()>)
When designing mutator methods taking &mut self that can fail due to invalid indices or out-of-bounds conditions:
- Why
&mut selfMutators Must Heap-Allocate Text Payloads: In Rust, a&mut selfmutator that deletes or replaces text cannot returnOption<&str>or zero-allocation byte offsets (DocSeg), because:- The borrow checker forbids returning a
&strreference borrowing fromselfacross a&mut selfmutation. - Once deleted from
self, the text bytes no longer exist in memory, invalidating any borrowed slices or offset metadata. - Therefore, returning deleted/replaced text payload unavoidably requires an owned heap allocation (
Option<String>).
- The borrow checker forbids returning a
- Returning Removed/Replaced Payloads (
Option<T>): Return a payloadOption<T>(e.g.,Option<LineMetadata>for zero-allocation structural metrics, or ownedOption<String>for text) ONLY when callers genuinely consume the deleted payload. - Zero-Allocation Success/Failure (
Option<()>overbool): If callers do not consume the deleted text payload, do NOT incur speculative heap allocations (Option<String>). Instead, returnOption<()>(Some(())for success,Nonefor failure/out-of-bounds).Option<()>provides the exact same zero-allocation CPU-register performance as a rawboolwhile eliminating boolean blindness and supporting the?try operator.
Clean Imports over Inline Absolute Paths (Mandatory)
Do NOT write absolute inline paths like crate::Type or crate::Size inside function
signatures or bodies; instead, import them cleanly via use statements at the top of the
file, then reference the type directly. This keeps code highly readable and reduces
cognitive clutter. When writing generated code, make sure to use the remove-crate-prefix
skill to automate this clean up so generated code is not littered with crate::<T>.
✅ Good:
use crate::{Size, Pos};
pub fn render(size: Size) -> Pos { ... }❌ Bad:
pub fn render(size: crate::Size) -> crate::Pos { ... }Macro Imports
Do NOT use #[macro_use] on module declarations. For #[macro_export] macros, use
explicit imports: use crate::macro_name;. Each mod block that uses a macro needs its
own import - parent scope imports don't propagate into child modules.
Cross-Platform Verification
When working with platform-specific code (#[cfg(unix)], #[cfg(not(unix))]), verify
Windows compatibility. This performs type checking and borrow checking for the Windows
target without full code generation or linking.
Note: While --emit=metadata skips the linking stage, the mingw-w64 toolchain is still
required because many core dependencies (like windows-sys, parking_lot, or
mimalloc) have build scripts that probe for x86_64-w64-mingw32-gcc and
x86_64-w64-mingw32-dlltool.
cargo rustc -p <crate_name> --target x86_64-pc-windows-gnu -- --emit=metadataUse this after modifying DirectToAnsi input handling or other Unix-specific code.
Testing Interactive Terminal Applications
For testing interactive terminal applications, use (both are installed):
tmuxscreen
Prefer ? Operator over .and_then() (Mandatory)
Do NOT use .and_then() for chaining Option or Result operations in code. Instead,
write idiomatic Rust using early returns with the ? operator (or if let / let-else
statements). The only acceptable exception is for boolean constant gating in
tracing/logging calls if necessary, though even then, canonical Rust is preferred.
✅ Good:
fn get_char(&self, pos: Pos) -> Option<PixelChar> {
let row = self.get_row(pos.row_index)?;
let cell = row.get(pos.col_index.as_usize())?;
Some(*cell)
}❌ Bad:
fn get_char(&self, pos: Pos) -> Option<PixelChar> {
self.get_row(pos.row_index)
.and_then(|row| row.get(pos.col_index.as_usize()))
.copied()
}Prefer FxHashMap and FxHashSet over Standard HashMap and HashSet (Mandatory)
Do NOT use standard std::collections::HashMap or std::collections::HashSet in this
codebase. Standard library maps use SipHash 1-3 by default to protect against network
Hash-DoS collision attacks, which is completely unnecessary for local TUI and CLI
applications.
Instead, always import and use rustc_hash::FxHashMap and rustc_hash::FxHashSet
(from the rustc-hash = "2.1.0" crate). FxHasher runs in ~1 CPU cycle using simple
arithmetic shifts and multiplications, drastically cutting hashing overhead (up to 87%
reduction in flamegraphs).
✅ Good:
use rustc_hash::FxHashMap;
let mut map = FxHashMap::default();
map.insert(key, value);❌ Bad:
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert(key, value);Git Workflow
PR Lifecycle & Commands
We have a cohesive, interconnected lifecycle for Pull Requests codified in
.agents/skills/:
- Start a new task:
/fix-issue- Creates the branch, pushes it, and opens a Draft PR (
gh pr create --draft) to track the work.
- Creates the branch, pushes it, and opens a Draft PR (
- Review community work:
/review-pr- Fetches an existing PR to systematically audit, test, and rewrite locally.
- Manual PR creation:
/create-pr- For when you have local changes on a branch and just want to push and open a PR
(
gh pr create --fill) without going through the full/fix-issuedesign process.
- For when you have local changes on a branch and just want to push and open a PR
(
- Merge and complete:
/merge-pr- The endpoint for all of the above. Pushes the finalized local branch and linearly
merges the existing PR (
gh pr merge --rebase), then cleans up the local workspace.
- The endpoint for all of the above. Pushes the finalized local branch and linearly
merges the existing PR (
General Rules
- No Destructive Resets: NEVER use
git reset HEAD~n,git reset --hard, orgit cleanunless explicitly and specifically commanded to do so by the user. These commands are destructive to the user's work and staging area. - No Clobbering Existing Edits: NEVER use
git checkoutorgit restoreto overwrite existing files in the working tree unless explicitly and specifically commanded to do so by the user. This can destroy uncommitted work. - Surgical Unstaging: When asked to unstage specific files, ALWAYS use targeted
commands like
git restore --staged <file>. NEVER unstage the entire index or use blanket reset commands if a specific list of files is provided. - Respect the Index: The staging area is the user's carefully curated state. Do not
perform any action that clears or modifies the entire index (like blanket
git reset) unless that is exactly what was requested. - Never use
git stash/git stash popto test against clean state - it destroys the staging area (index). Use the Task tool withisolation: "worktree"to run tests in a separate git worktree without touching the main working tree. - Use
git mvinstead ofmvwhen moving or renaming files to preserve move history in git. - Never commit unless explicitly asked
When you do make commits, do not add an attribution to yourself in the commit message. Do not add the following trailing lines (or similar) in a commit message:
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Git and GitHub CLI (gh) Usage
- GitHub CLI (
gh): Works out of the box (uses session tokens). - Git Read-only (
fetch,pull): Works for public repositories. - Git Push: Requires a terminal (TTY) for credential prompts. In non-interactive agent environments (where prompts are disabled), Git may fail even if credentials are stored. To bypass this, explicitly force a credential helper to avoid the TTY check:
# Option A: Use GitHub CLI (recommended if gh is authenticated)
git -c credential.helper='!gh auth git-credential' push origin my-branch
# Option B: Use the local store (if ~/.git-credentials is set up)
git -c credential.helper=store push origin my-branchCommit Message Format
When creating or formatting a commit message, you MUST invoke and follow the
create-commit-message skill. It contains all the detailed rules for formatting (72-char
limits, trailers, scope prefixes).
Task Tracking System
The /r3bl-task slash command is available to manage all the details of a long-running
task. Follow the Standard Workflow (Alignment -> Plan -> Execute) when using this
system. All tasks are stored in the ./task/ directory as individual Markdown files.
Task File Formatting
Always run prettier --write <file> on any task/*.md files after creating or updating
them. This ensures markdown is correctly formatted and easy to review in the user's IDE.
Folder Structure
task/- Active tasks (currently being worked on).task/pending/- Future tasks (not yet started).task/done/- Completed tasks.task/archive/- Abandoned tasks kept for historical reference.
See task/AGENTS.md for detailed rules on managing individual task files.
Skill Details
For detailed information on any skill, see .agents/skills/<skill-name>/SKILL.md. Each
skill includes:
- SKILL.md - Main instructions and workflow
- Supporting files - Detailed examples, patterns, references, and decision trees
The skills contain all the detailed guidance that was previously in this file, now organized for autonomous discovery and reuse.
Large Refactoring Scenarios
When executing large-scale, tree-wide refactoring tasks (such as mass renaming variables,
fields, or types across many files), agents MUST activate the safe-renaming skill and
follow these safety protocols:
- Use Built-in Tools First: Always attempt to use the built-in, precise file
modification tools (
multi_replace_file_contentorreplace_file_content) if the scope of the refactor is small enough to be handled safely file-by-file. - BTRFS Staging Copy (
cp --reflink=auto): For tree-wide refactoring, create a BTRFS reflink clone of the workspace at~/Downloads/rename-staging/before modifying any files. Never usetmpfsas build artifacts can exhaust RAM. - Custom Rust Script with
--dry-run: Create a disposable Rust (rustc) script with a mandatory--dry-runCLI argument and strict word boundary matching (\bor!is_alphanumeric() && c != '_'). - Staging Execution & Verification: Run
--dry-runon~/Downloads/rename-staging/, apply the changes there, and run the full test suite (cargo check,cargo clippy,cargo test,cargo doc) inside the staging directory. - Apply to Live Repo: IF AND ONLY IF all tests pass 100% in
~/Downloads/rename-staging/, remove the staging directory and run the refactoring binary on the live workspace (~/github/roc). - Reference Skill: See
.agents/skills/safe-renaming/SKILL.mdfor full instructions.
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.

