swe-programming-rust
Rust coding standards from authoritative docs/explanation/software-engineering/programming-languages/rust/ documentation
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Rust coding standards from authoritative docs/explanation/software-engineering/programming-languages/rust/ documentation
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
AI agent development standards including frontmatter structure, naming conventions, tool access patterns, model selection, and reference documentation structure
Comprehensive project planning standards for plans/ directory including folder structure (ideas/, backlog/, in-progress/, done/), stage-aware naming convention (done uses YYYY-MM-DD__identifier/; backlog and in-progress use identifier/ with no date prefix), five-document file organization (README.md, brd.md, prd.md, tech-docs.md, delivery.md for multi-file default; single README.md for trivially-small single-file exception), BRD/PRD content-placement rules, Gherkin acceptance criteria, and the mandatory structured multiple-choice grilling gates (pre-write and post-write) for resolving design decisions with the user. Essential for creating structured, executable project plans.
Trunk Based Development workflow - all development on main branch with small frequent commits, minimal branching, and continuous integration. Covers when branches are justified (exceptional cases only), commit patterns, feature flag usage for incomplete work, environment branch rules (deployment only), and AI agent default behavior (the repo-wide default delivery mode is `worktree-to-pr` -- a short-lived plan branch in a disposable worktree pushed to a draft PR; direct push to main remains available as an explicit selection). Essential for understanding repository git workflow and keeping branches short-lived
Workflow pattern standards for creating multi-agent orchestrations including YAML frontmatter (name, description, tags, status, agents, parameters), execution phases (sequential/parallel/conditional), agent coordination patterns, and Gherkin success criteria. Essential for defining reusable, validated workflow processes.
Common software development workflow patterns shared across all language developer agents
Three-stage content quality workflow pattern (Maker creates, Checker validates, Fixer remediates) with detailed execution workflows. Use when working with content quality workflows, validation processes, audit reports, or implementing maker/checker/fixer agent roles.
| name | swe-programming-rust |
| description | Rust coding standards from authoritative docs/explanation/software-engineering/programming-languages/rust/ documentation |
Progressive disclosure of Rust coding standards for agents writing Rust code.
Usage: Auto-loaded for agents when writing Rust code. Provides quick reference to idioms, best practices, and antipatterns.
Authoritative Source: docs/explanation/software-engineering/programming-languages/rust/README.md
IMPORTANT: This skill provides demo-specific style guides, not educational tutorials.
Complete the demo Rust learning path first:
Types/Traits/Enums: PascalCase - ZakatCalculator, MurabahaContract, PaymentStatus
Functions/Variables/Modules: snake_case - calculate_zakat, total_amount, zakat_service
Constants/Statics: UPPER_SNAKE_CASE - MAX_NISAB_THRESHOLD, ZAKAT_RATE
Lifetimes: short lowercase - 'a, 'b (descriptive when helpful: 'contract)
// CORRECT: thiserror for domain errors
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ZakatError {
#[error("Wealth cannot be negative: {0}")]
NegativeWealth(rust_decimal::Decimal),
#[error("Repository error: {0}")]
Repository(#[from] sqlx::Error),
}
// CORRECT: Result<T,E> for fallible operations
pub fn calculate_zakat(
wealth: Decimal,
nisab: Decimal,
) -> Result<Decimal, ZakatError> {
if wealth < Decimal::ZERO {
return Err(ZakatError::NegativeWealth(wealth));
}
Ok(if wealth >= nisab { wealth * dec!(0.025) } else { Decimal::ZERO })
}
// CORRECT: ? operator for propagation
pub async fn process_payment(wealth: Decimal) -> Result<Payment, ZakatError> {
let nisab = repository.get_nisab().await?;
let amount = calculate_zakat(wealth, nisab)?;
Ok(Payment::new(amount))
}
// WRONG: unwrap() without justification
let amount = calculate_zakat(wealth, nisab).unwrap(); // PANICS!
// CORRECT: Borrow when possible, own when necessary
fn format_contract(contract: &MurabahaContract) -> String {
format!("Contract {}: {}", contract.id, contract.amount)
}
// CORRECT: Own when returning or storing
fn create_contract(id: String, amount: Decimal) -> MurabahaContract {
MurabahaContract { id, amount }
}
// WRONG: Cloning unnecessarily
fn bad_format(contract: MurabahaContract) -> String { // Moves contract!
format!("Contract {}", contract.id)
}
// CORRECT: Iterator combinators (zero-cost abstractions)
let total_zakat: Decimal = contracts
.iter()
.filter(|c| c.wealth >= nisab_threshold)
.map(|c| c.wealth * dec!(0.025))
.sum();
// WRONG: Manual loop when iterators work
let mut total = Decimal::ZERO;
for contract in &contracts {
if contract.wealth >= nisab_threshold {
total += contract.wealth * dec!(0.025);
}
}
// CORRECT: Newtype for type-safe IDs
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ContractId(String);
impl ContractId {
pub fn new(id: impl Into<String>) -> Self {
Self(id.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
// WRONG: Using raw strings for IDs
fn get_contract(id: String) -> Option<MurabahaContract> { ... }
// Can accidentally pass wrong string
// CORRECT: Axum handler with State and error handling
use axum::{extract::{Path, State}, Json, http::StatusCode};
async fn calculate_zakat_handler(
State(repo): State<Arc<dyn ZakatRepository>>,
Json(request): Json<ZakatRequest>,
) -> Result<Json<ZakatResponse>, (StatusCode, String)> {
let nisab = repo.get_nisab().await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
let amount = calculate_zakat(request.wealth, nisab)
.map_err(|e| (StatusCode::BAD_REQUEST, e.to_string()))?;
Ok(Json(ZakatResponse { amount }))
}
# .rustfmt.toml
edition = "2021"
max_width = 100
use_field_init_shorthand = true
# Run before commit
cargo fmt --check # Check formatting
cargo clippy -- -D warnings # Fail on any warning
cargo test # Run all tests
Authoritative Index: docs/explanation/software-engineering/programming-languages/rust/README.md