This repository is a Rust-based coding agent, currently called claw-code-rust.
- All crate names use the
clawcr-prefix. For instance, the crate in thecoredirectory is namedclawcr-core. - When using
format!, inline variables directly inside{}whenever possible. - Always collapse nested
ifstatements according to https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if - Inline
format!arguments whenever possible, following https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args - Prefer method references instead of closures where applicable, per https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
- Avoid using
boolor unclearOptionparameters that lead to ambiguous calls likefoo(false)orbar(None). Instead, use enums, clearly named methods, newtypes, or other idiomatic Rust patterns that improve readability at the callsite. - If such API changes are not feasible and positional literals must still be used, follow the
argument_comment_lintrule:- Add an exact
/*param_name*/comment before unclear positional literals (e.g.,None, booleans, numeric values). - Do not include these comments for string or character literals unless they genuinely improve clarity, as these are exempt.
- The comment must exactly match the parameter name in the function signature.
- Add an exact
- Make
matchexpressions exhaustive whenever possible, avoiding wildcard arms. - Any newly introduced traits must include documentation explaining their purpose and how implementations should behave.
- In tests, favor comparing full objects rather than asserting on individual fields.
- If an API is added or modified, update the relevant documentation in the
docs/directory when necessary. - Avoid introducing small helper functions that are only used once.
- Keep modules reasonably sized:
- Prefer creating new modules instead of expanding existing ones.
- Aim to keep modules under 500 lines of code, excluding tests.
- If a file grows beyond ~800 lines, place new functionality in a separate module unless there is a strong, documented justification not to.
- When running Rust-related commands (e.g.,
just fixorcargo test), allow them to complete without interruption, do not try to kill them using the PID. Slow execution due to Rust’s locking behavior is expected.
- Use
pretty_assertions::assert_eqin tests to produce clearer diffs. Import it at the top of the test module if it’s not already present. - Prefer deep equality checks by asserting entire objects instead of comparing fields individually.
- Do not mutate process environment variables in tests; instead, pass environment-dependent values or flags explicitly from higher levels.