with one click
write-code
// Rust code style and conventions for Syncpack. Use when writing or modifying Rust code. Covers functional patterns, imports, naming, and quality standards.
// Rust code style and conventions for Syncpack. Use when writing or modifying Rust code. Covers functional patterns, imports, naming, and quality standards.
Write tests for Syncpack using the TestBuilder pattern. Use when adding tests for commands, validation logic, or any new functionality. Covers TestBuilder API, assertion patterns, and common test scenarios.
Run coverage, inspect results, and identify missing test scenarios for a given source file. Use when analysing test coverage or finding untested branches.
Add new features to Syncpack including commands and validation logic. Use when implementing new CLI commands, adding InstanceState variants, or extending version group behaviour.
Add and update the documentation website for Syncpack. Use when making user-facing changes to the codebase.
Debug and fix bugs in Syncpack using scientific debugging methodology. Use when a test is failing, unexpected behaviour occurs, or investigating issues. Covers hypothesis-driven debugging and TDD-based fixes.
Put the answer first, then context and details follow. Use when writing documentation, tutorials, error messages, or any communication where readers need to decide quickly if something is relevant to them.
| name | write-code |
| description | Rust code style and conventions for Syncpack. Use when writing or modifying Rust code. Covers functional patterns, imports, naming, and quality standards. |
Rust code conventions for Syncpack.
? chains: use .and_then(), .map(), .or_else()println!("{var}") not println!("{}", var)Single use statement with grouped braces:
use {
crate::{cli::Cli, config::Config},
log::{debug, error},
std::{process::exit, sync::Arc},
};
Rules:
super:: — always crate:: for internal importscrate::, external crates, std::| Adding... | Location |
|---|---|
| New command | src/commands/{name}.rs |
| New test | Sibling _test.rs file (e.g., src/foo.rs → src/foo_test.rs) |
NEVER use #[cfg(test)] modules inside implementation files.
just format before committing//! module docs — collect implementation history and rot// Phase v4-2, // F16:, banner headers like // ---------- Phase v4-3 RED ----------Migrated from, carry-over, Mirrors v3, replaces the v3, previously inside X, reserved for futureReproduces issue #239, GitHub issue #206. Plans rot; the code is the truth// ---------- Free functions: yaml ops ----------. Use module structure or let the file speak for itself// Windows-style backslashes above a test input. Use a descriptive variable binding (let windows_backslashes = [...]) instead/// A unique identifier for this instance, /// The dependency name, /// The instance id. The field name already says it// 1. ..., // 2. .... Drop the numbers; keep the WHY if it's non-obvious@TODO markers — future plans worth tracking inline/// doc comments for non-obvious detail: None/Err semantics, side effects, invariants, distinctions between similar fields (e.g. is_local_dependency vs is_local_instance)// inline comments when WHY is non-obvious: hidden constraints, ordering invariants ("SnappedTo groups must be visited last"), workarounds for surprising library behaviour, "must not poison X" cautionsNo comments. Add one only when the WHY is non-obvious to a fresh reader.
ctx.version_groups.iter().for_each(|group| {
group.get_sorted_dependencies(&ctx.config.cli.sort).for_each(|dependency| {
dependency.get_sorted_instances()
.filter(|instance| instance.is_invalid())
.for_each(|instance| { /* process */ });
});
});
Prefer combinators over ?:
// Good
path.parent()
.and_then(|p| p.to_str())
.map(|s| s.to_string())
.unwrap_or_default()
// Avoid
let parent = path.parent()?;
let str = parent.to_str()?;
Ok(str.to_string())
let mut state = instance.state.borrow_mut();
if !state.is_invalid() {
*state = InstanceState::fixable(SomeVariant);
}