بنقرة واحدة
rust-conventions
Rust coding conventions and patterns for service development.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Rust coding conventions and patterns for service development.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Generate and complete reusable security test documents under docs/security/ based on the current project implementation and/or a confirmed plan. Use when a developer asks to complete security test docs, add missing security scenarios, or establish a security test baseline for the project.
Generate and maintain reusable UI/UX test documents under docs/uiux/ based on the current project UI implementation and the design-system constraints. Use when a developer asks to complete UI/UX test docs, add missing UI/UX scenarios, align UI constraints, or wants UI consistency/a11y/responsive regression checks during development.
Guide for working with the Agent Orchestrator — a CLI tool for AI-native SDLC automation. Use when writing or editing YAML manifests (Workspace, Agent, Workflow, StepTemplate, ExecutionProfile, SecretStore, EnvStore, Trigger, CRD), running orchestrator CLI commands, designing workflow step pipelines, writing CEL prehook/finalize expressions, configuring triggers (cron/event-driven task creation), or configuring self-bootstrap workflows. Triggers: any mention of orchestrator config, YAML manifests with "orchestrator.dev/v2", workflow steps, prehooks, finalize rules, task create/start/pause, orchestrator run, step filtering, direct assembly, agent capabilities, StepTemplate prompts, execution profiles, sandbox configuration, secret management, or trigger/cron scheduling.
Govern feature request (FR) documents through their full lifecycle — from planning to implementation to closure. Use when the user asks to govern/治理 a feature request, close an FR, check FR status, or says "治理FR", "/fr-governance". Scans docs/feature_request/ for open FR docs, plans implementation, executes governance, and self-checks closure.
Generate or update QA/security/UIUX test documentation after confirmed feature implementation plans or completed refactors. Use this skill AFTER plan approval or code completion to: (1) add new QA test docs for new behavior, (2) generate design docs, and (3) run repo-wide cross-doc impact analysis (docs/qa/, docs/security/, docs/uiux/, docs/guide/ and its translations, docs/design_doc/, docs/showcases/, root Markdown including CHANGELOG.md, and .claude/skills/) to update stale steps, expectations, and assertions. Triggers when users ask to create QA docs, update test docs after implementation, or sync QA/security/UIUX docs after behavior changes.
Govern and periodically remediate QA documentation quality across docs/qa, docs/security, and docs/uiux. Use when users ask to audit QA docs, run recurring documentation checks, fix doc drift after refactors, enforce scenario limits/checklists/UI entry visibility, or synchronize README/manifest/changelog consistency.
| name | rust-conventions |
| description | Rust coding conventions and patterns for service development. |
These are recommended defaults; adjust to your stack.
| Component | Suggested Library |
|---|---|
| Web | axum (+ tower middleware) |
| gRPC | tonic |
| Database | sqlx |
| Async | tokio |
| Logging | tracing |
| Testing | mockall, wiremock |
src/
├── domain/ # Pure models with validation
├── service/ # Business logic (depends on repo traits)
├── repository/ # Data access (mockable traits)
├── api/ # HTTP handlers (thin)
├── grpc/ # gRPC handlers (thin)
└── cache/ # Cache facade + NoOp cache for tests (optional)
// ❌ BAD
let result = db.query().await.ok();
// ✅ GOOD - use Result with context
let result = db.query()
.await
.context("Failed to query tenant")?;
// ✅ GOOD - custom error types
#[derive(thiserror::Error, Debug)]
pub enum ServiceError {
#[error("Tenant not found: {0}")]
TenantNotFound(Uuid),
#[error("Database error: {0}")]
Database(#[from] sqlx::Error),
}
All tests run fast (~1-2s) with no Docker:
| Component | Approach |
|---|---|
| Repository | Mock traits with mockall |
| Service | Unit tests with mock repos |
| gRPC | NoOpCacheManager + mocks |
| Keycloak | wiremock HTTP mocking |
#[cfg_attr(test, mockall::automock)]
#[async_trait]
pub trait TenantRepository: Send + Sync {
async fn create(&self, input: &CreateTenantInput) -> Result<Tenant>;
async fn find_by_id(&self, id: StringUuid) -> Result<Option<Tenant>>;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::repository::tenant::MockTenantRepository;
#[tokio::test]
async fn test_create_tenant() {
let mut mock = MockTenantRepository::new();
mock.expect_find_by_slug()
.returning(|_| Ok(None));
mock.expect_create()
.returning(|input| Ok(Tenant { name: input.name.clone(), ..Default::default() }));
let service = TenantService::new(Arc::new(mock), None);
let result = service.create(input).await;
assert!(result.is_ok());
}
}
use crate::cache::NoOpCacheManager;
#[tokio::test]
async fn test_exchange_token() {
let cache = NoOpCacheManager::new(); // No Redis
let service = TokenExchangeService::new(jwt_manager, cache, repos...);
// ...
}
use wiremock::{Mock, ResponseTemplate, MockServer};
#[tokio::test]
async fn test_keycloak() {
let mock_server = MockServer::start().await;
Mock::given(method("POST"))
.and(path("/realms/master/protocol/openid-connect/token"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"access_token": "mock-token"
})))
.mount(&mock_server).await;
// Use mock_server.uri()
}
cargo test # All tests (fast)
cargo llvm-cov --html # Coverage report
cargo clippy # Lint
cargo fmt # Format