@heyai-rules/pilo-masterkit 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/agents/PILO_MASTER.md +77 -0
- package/.agent/agents/architect.md +211 -0
- package/.agent/agents/backend-specialist.md +263 -0
- package/.agent/agents/build-error-resolver.md +114 -0
- package/.agent/agents/chief-of-staff.md +151 -0
- package/.agent/agents/code-archaeologist.md +106 -0
- package/.agent/agents/code-reviewer.md +237 -0
- package/.agent/agents/cpp-build-resolver.md +90 -0
- package/.agent/agents/cpp-reviewer.md +72 -0
- package/.agent/agents/database-architect.md +226 -0
- package/.agent/agents/database-reviewer.md +91 -0
- package/.agent/agents/debugger.md +225 -0
- package/.agent/agents/devops-engineer.md +242 -0
- package/.agent/agents/doc-updater.md +107 -0
- package/.agent/agents/docs-lookup.md +68 -0
- package/.agent/agents/documentation-writer.md +104 -0
- package/.agent/agents/e2e-runner.md +107 -0
- package/.agent/agents/explorer-agent.md +73 -0
- package/.agent/agents/flutter-reviewer.md +243 -0
- package/.agent/agents/frontend-specialist.md +593 -0
- package/.agent/agents/game-developer.md +162 -0
- package/.agent/agents/go-build-resolver.md +94 -0
- package/.agent/agents/go-reviewer.md +76 -0
- package/.agent/agents/harness-optimizer.md +35 -0
- package/.agent/agents/java-build-resolver.md +153 -0
- package/.agent/agents/java-reviewer.md +92 -0
- package/.agent/agents/kotlin-build-resolver.md +118 -0
- package/.agent/agents/kotlin-reviewer.md +159 -0
- package/.agent/agents/loop-operator.md +36 -0
- package/.agent/agents/mobile-developer.md +377 -0
- package/.agent/agents/orchestrator.md +416 -0
- package/.agent/agents/penetration-tester.md +188 -0
- package/.agent/agents/performance-optimizer.md +187 -0
- package/.agent/agents/planner.md +212 -0
- package/.agent/agents/product-manager.md +112 -0
- package/.agent/agents/product-owner.md +95 -0
- package/.agent/agents/project-planner.md +406 -0
- package/.agent/agents/python-reviewer.md +98 -0
- package/.agent/agents/pytorch-build-resolver.md +120 -0
- package/.agent/agents/qa-automation-engineer.md +103 -0
- package/.agent/agents/refactor-cleaner.md +85 -0
- package/.agent/agents/rust-build-resolver.md +148 -0
- package/.agent/agents/rust-reviewer.md +94 -0
- package/.agent/agents/security-auditor.md +170 -0
- package/.agent/agents/security-reviewer.md +108 -0
- package/.agent/agents/seo-specialist.md +111 -0
- package/.agent/agents/tdd-guide.md +91 -0
- package/.agent/agents/test-engineer.md +158 -0
- package/.agent/agents/typescript-reviewer.md +112 -0
- package/.agent/rules/ARCHITECTURAL_BLUEPRINTS.md +62 -0
- package/.agent/rules/CODE_CRAFTSMANSHIP.md +69 -0
- package/.agent/rules/CORE_RULES.md +72 -0
- package/.agent/rules/PROJECT_MAP.md +58 -0
- package/.agent/rules/QUALITY_ASSURANCE.md +54 -0
- package/.agent/rules/SECURITY_ARMOR.md +44 -0
- package/.agent/rules/VERSION_ORCHESTRATION.md +64 -0
- package/.agent/rules/WORKFLOW_ORCHESTRATION.md +55 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +41 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/bash-linux/SKILL.md +199 -0
- package/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/.agent/skills/brainstorming/SKILL.md +163 -0
- package/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/.agent/skills/database-design/SKILL.md +52 -0
- package/.agent/skills/database-design/database-selection.md +43 -0
- package/.agent/skills/database-design/indexing.md +39 -0
- package/.agent/skills/database-design/migrations.md +48 -0
- package/.agent/skills/database-design/optimization.md +36 -0
- package/.agent/skills/database-design/orm-selection.md +30 -0
- package/.agent/skills/database-design/schema-design.md +56 -0
- package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/.agent/skills/frontend-design/SKILL.md +452 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/.agent/skills/game-development/SKILL.md +167 -0
- package/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/mobile-design/SKILL.md +394 -0
- package/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/.agent/skills/mobile-design/mobile-typography.md +433 -0
- package/.agent/skills/mobile-design/platform-android.md +666 -0
- package/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +351 -0
- package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/.agent/skills/nextjs-react-expert/9-cache-components.md +103 -0
- package/.agent/skills/nextjs-react-expert/SKILL.md +293 -0
- package/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/.agent/skills/plan-writing/SKILL.md +152 -0
- package/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/.agent/skills/python-patterns/SKILL.md +441 -0
- package/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/.agent/skills/rust-pro/SKILL.md +176 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/.agent/skills/server-management/SKILL.md +161 -0
- package/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +292 -0
- package/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/.agent/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/.agent/skills/ui-ux-pro-max/scripts/__pycache__/search.cpython-314.pyc +0 -0
- package/.agent/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/.agent/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/skills/ui-ux-pro-max/scripts/search.py +114 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/.agent/tasks/lessons.md +40 -0
- package/.agent/tasks/todo.md +33 -0
- package/.agent/workflows/aside.md +164 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/build-fix.md +62 -0
- package/.agent/workflows/checkpoint.md +74 -0
- package/.agent/workflows/claw.md +51 -0
- package/.agent/workflows/code-review.md +40 -0
- package/.agent/workflows/context-budget.md +29 -0
- package/.agent/workflows/cpp-build.md +173 -0
- package/.agent/workflows/cpp-review.md +132 -0
- package/.agent/workflows/cpp-test.md +251 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/devfleet.md +92 -0
- package/.agent/workflows/docs.md +31 -0
- package/.agent/workflows/e2e.md +365 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/eval.md +120 -0
- package/.agent/workflows/evolve.md +178 -0
- package/.agent/workflows/go-build.md +183 -0
- package/.agent/workflows/go-review.md +148 -0
- package/.agent/workflows/go-test.md +268 -0
- package/.agent/workflows/gradle-build.md +70 -0
- package/.agent/workflows/harness-audit.md +71 -0
- package/.agent/workflows/init-docs.md +46 -0
- package/.agent/workflows/instinct-export.md +66 -0
- package/.agent/workflows/instinct-import.md +114 -0
- package/.agent/workflows/instinct-status.md +59 -0
- package/.agent/workflows/kotlin-build.md +174 -0
- package/.agent/workflows/kotlin-review.md +140 -0
- package/.agent/workflows/kotlin-test.md +312 -0
- package/.agent/workflows/learn-eval.md +116 -0
- package/.agent/workflows/learn.md +70 -0
- package/.agent/workflows/loop-start.md +32 -0
- package/.agent/workflows/loop-status.md +24 -0
- package/.agent/workflows/model-route.md +26 -0
- package/.agent/workflows/multi-backend.md +158 -0
- package/.agent/workflows/multi-execute.md +315 -0
- package/.agent/workflows/multi-frontend.md +158 -0
- package/.agent/workflows/multi-plan.md +268 -0
- package/.agent/workflows/multi-workflow.md +191 -0
- package/.agent/workflows/orchestrate.md +231 -0
- package/.agent/workflows/plan.md +115 -0
- package/.agent/workflows/pm2.md +272 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/projects.md +39 -0
- package/.agent/workflows/promote.md +41 -0
- package/.agent/workflows/prompt-optimize.md +38 -0
- package/.agent/workflows/prune.md +31 -0
- package/.agent/workflows/python-review.md +297 -0
- package/.agent/workflows/quality-gate.md +29 -0
- package/.agent/workflows/refactor-clean.md +80 -0
- package/.agent/workflows/resume-session.md +156 -0
- package/.agent/workflows/rules-distill.md +11 -0
- package/.agent/workflows/rust-build.md +187 -0
- package/.agent/workflows/rust-review.md +142 -0
- package/.agent/workflows/rust-test.md +308 -0
- package/.agent/workflows/save-session.md +275 -0
- package/.agent/workflows/sessions.md +333 -0
- package/.agent/workflows/setup-pm.md +80 -0
- package/.agent/workflows/skill-create.md +174 -0
- package/.agent/workflows/skill-health.md +54 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/tdd.md +328 -0
- package/.agent/workflows/test-coverage.md +69 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.agent/workflows/update-codemaps.md +72 -0
- package/.agent/workflows/update-docs.md +84 -0
- package/.agent/workflows/verify.md +59 -0
- package/LICENSE +176 -0
- package/README.md +136 -0
- package/RELEASE.md +36 -0
- package/package.json +79 -0
- package/scripts/release-check.js +55 -0
- package/src/bin/cli.js +78 -0
- package/src/lib/installer.js +140 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fix Rust build errors, borrow checker issues, and dependency problems incrementally. Invokes the rust-build-resolver agent for minimal, surgical fixes.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Rust Build and Fix
|
|
6
|
+
|
|
7
|
+
This command invokes the **rust-build-resolver** agent to incrementally fix Rust build errors with minimal changes.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Run Diagnostics**: Execute `cargo check`, `cargo clippy`, `cargo fmt --check`
|
|
12
|
+
2. **Parse Errors**: Identify error codes and affected files
|
|
13
|
+
3. **Fix Incrementally**: One error at a time
|
|
14
|
+
4. **Verify Each Fix**: Re-run `cargo check` after each change
|
|
15
|
+
5. **Report Summary**: Show what was fixed and what remains
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
Use `/rust-build` when:
|
|
20
|
+
- `cargo build` or `cargo check` fails with errors
|
|
21
|
+
- `cargo clippy` reports warnings
|
|
22
|
+
- Borrow checker or lifetime errors block compilation
|
|
23
|
+
- Cargo dependency resolution fails
|
|
24
|
+
- After pulling changes that break the build
|
|
25
|
+
|
|
26
|
+
## Diagnostic Commands Run
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Primary build check
|
|
30
|
+
cargo check 2>&1
|
|
31
|
+
|
|
32
|
+
# Lints and suggestions
|
|
33
|
+
cargo clippy -- -D warnings 2>&1
|
|
34
|
+
|
|
35
|
+
# Formatting check
|
|
36
|
+
cargo fmt --check 2>&1
|
|
37
|
+
|
|
38
|
+
# Dependency issues
|
|
39
|
+
cargo tree --duplicates
|
|
40
|
+
|
|
41
|
+
# Security audit (if available)
|
|
42
|
+
if command -v cargo-audit >/dev/null; then cargo audit; else echo "cargo-audit not installed"; fi
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Example Session
|
|
46
|
+
|
|
47
|
+
````text
|
|
48
|
+
User: /rust-build
|
|
49
|
+
|
|
50
|
+
Agent:
|
|
51
|
+
# Rust Build Resolution
|
|
52
|
+
|
|
53
|
+
## Initial Diagnostics
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
$ cargo check
|
|
57
|
+
error[E0502]: cannot borrow `map` as mutable because it is also borrowed as immutable
|
|
58
|
+
--> src/service/cache.rs:25:5
|
|
59
|
+
error[E0308]: mismatched types
|
|
60
|
+
--> src/handler/api.rs:42:12
|
|
61
|
+
error[E0425]: cannot find value `db` in this scope
|
|
62
|
+
--> src/handler/api.rs:58:9
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Errors found: 3
|
|
66
|
+
|
|
67
|
+
## Fix 1: Borrow Checker Error
|
|
68
|
+
|
|
69
|
+
File: src/service/cache.rs:25
|
|
70
|
+
Error: E0502 — cannot borrow `map` as mutable because also borrowed as immutable
|
|
71
|
+
Cause: Immutable borrow still active during mutable insert
|
|
72
|
+
|
|
73
|
+
```rust
|
|
74
|
+
// Changed: restructured to end immutable borrow before mutable access
|
|
75
|
+
if !map.contains_key("key") {
|
|
76
|
+
map.insert("key".into(), default);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
$ cargo check
|
|
82
|
+
# 2 errors remaining
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Fix 2: Type Mismatch
|
|
86
|
+
|
|
87
|
+
File: src/handler/api.rs:42
|
|
88
|
+
Error: E0308 — mismatched types: expected `usize`, found `&str`
|
|
89
|
+
|
|
90
|
+
```rust
|
|
91
|
+
// Changed
|
|
92
|
+
let count = params.get("count");
|
|
93
|
+
// To
|
|
94
|
+
let count: usize = params.get("count")
|
|
95
|
+
.and_then(|s| s.parse().ok())
|
|
96
|
+
.unwrap_or(0);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
$ cargo check
|
|
101
|
+
# 1 error remaining
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Fix 3: Unresolved Name
|
|
105
|
+
|
|
106
|
+
File: src/handler/api.rs:58
|
|
107
|
+
Error: E0425 — cannot find value `db` in this scope
|
|
108
|
+
Cause: Missing import
|
|
109
|
+
|
|
110
|
+
```rust
|
|
111
|
+
// Added
|
|
112
|
+
use crate::db;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
$ cargo check
|
|
117
|
+
# Build successful!
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Final Verification
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
$ cargo clippy -- -D warnings
|
|
124
|
+
# No warnings
|
|
125
|
+
|
|
126
|
+
$ cargo test
|
|
127
|
+
running 6 tests
|
|
128
|
+
test service::cache::tests::test_insert ... ok
|
|
129
|
+
test service::cache::tests::test_get ... ok
|
|
130
|
+
test handler::api::tests::test_parse_count ... ok
|
|
131
|
+
test handler::api::tests::test_missing_count ... ok
|
|
132
|
+
test handler::api::tests::test_db_import ... ok
|
|
133
|
+
test handler::api::tests::test_response ... ok
|
|
134
|
+
|
|
135
|
+
test result: ok. 6 passed; 0 failed; 0 ignored
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Summary
|
|
139
|
+
|
|
140
|
+
| Metric | Count |
|
|
141
|
+
|--------|-------|
|
|
142
|
+
| Build errors fixed | 3 |
|
|
143
|
+
| Clippy warnings fixed | 0 |
|
|
144
|
+
| Files modified | 2 |
|
|
145
|
+
| Remaining issues | 0 |
|
|
146
|
+
|
|
147
|
+
Build Status: SUCCESS
|
|
148
|
+
````
|
|
149
|
+
|
|
150
|
+
## Common Errors Fixed
|
|
151
|
+
|
|
152
|
+
| Error | Typical Fix |
|
|
153
|
+
|-------|-------------|
|
|
154
|
+
| `cannot borrow as mutable` | Restructure to end immutable borrow first; clone only if justified |
|
|
155
|
+
| `does not live long enough` | Use owned type or add lifetime annotation |
|
|
156
|
+
| `cannot move out of` | Restructure to take ownership; clone only as last resort |
|
|
157
|
+
| `mismatched types` | Add `.into()`, `as`, or explicit conversion |
|
|
158
|
+
| `trait X not implemented` | Add `#[derive(Trait)]` or implement manually |
|
|
159
|
+
| `unresolved import` | Add to Cargo.toml or fix `use` path |
|
|
160
|
+
| `cannot find value` | Add import or fix path |
|
|
161
|
+
|
|
162
|
+
## Fix Strategy
|
|
163
|
+
|
|
164
|
+
1. **Build errors first** - Code must compile
|
|
165
|
+
2. **Clippy warnings second** - Fix suspicious constructs
|
|
166
|
+
3. **Formatting third** - `cargo fmt` compliance
|
|
167
|
+
4. **One fix at a time** - Verify each change
|
|
168
|
+
5. **Minimal changes** - Don't refactor, just fix
|
|
169
|
+
|
|
170
|
+
## Stop Conditions
|
|
171
|
+
|
|
172
|
+
The agent will stop and report if:
|
|
173
|
+
- Same error persists after 3 attempts
|
|
174
|
+
- Fix introduces more errors
|
|
175
|
+
- Requires architectural changes
|
|
176
|
+
- Borrow checker error requires redesigning data ownership
|
|
177
|
+
|
|
178
|
+
## Related Commands
|
|
179
|
+
|
|
180
|
+
- `/rust-test` - Run tests after build succeeds
|
|
181
|
+
- `/rust-review` - Review code quality
|
|
182
|
+
- `/verify` - Full verification loop
|
|
183
|
+
|
|
184
|
+
## Related
|
|
185
|
+
|
|
186
|
+
- Agent: `agents/rust-build-resolver.md`
|
|
187
|
+
- Skill: `skills/rust-patterns/`
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Comprehensive Rust code review for ownership, lifetimes, error handling, unsafe usage, and idiomatic patterns. Invokes the rust-reviewer agent.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Rust Code Review
|
|
6
|
+
|
|
7
|
+
This command invokes the **rust-reviewer** agent for comprehensive Rust-specific code review.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Verify Automated Checks**: Run `cargo check`, `cargo clippy -- -D warnings`, `cargo fmt --check`, and `cargo test` — stop if any fail
|
|
12
|
+
2. **Identify Rust Changes**: Find modified `.rs` files via `git diff HEAD~1` (or `git diff main...HEAD` for PRs)
|
|
13
|
+
3. **Run Security Audit**: Execute `cargo audit` if available
|
|
14
|
+
4. **Security Scan**: Check for unsafe usage, command injection, hardcoded secrets
|
|
15
|
+
5. **Ownership Review**: Analyze unnecessary clones, lifetime issues, borrowing patterns
|
|
16
|
+
6. **Generate Report**: Categorize issues by severity
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
Use `/rust-review` when:
|
|
21
|
+
- After writing or modifying Rust code
|
|
22
|
+
- Before committing Rust changes
|
|
23
|
+
- Reviewing pull requests with Rust code
|
|
24
|
+
- Onboarding to a new Rust codebase
|
|
25
|
+
- Learning idiomatic Rust patterns
|
|
26
|
+
|
|
27
|
+
## Review Categories
|
|
28
|
+
|
|
29
|
+
### CRITICAL (Must Fix)
|
|
30
|
+
- Unchecked `unwrap()`/`expect()` in production code paths
|
|
31
|
+
- `unsafe` without `// SAFETY:` comment documenting invariants
|
|
32
|
+
- SQL injection via string interpolation in queries
|
|
33
|
+
- Command injection via unvalidated input in `std::process::Command`
|
|
34
|
+
- Hardcoded credentials
|
|
35
|
+
- Use-after-free via raw pointers
|
|
36
|
+
|
|
37
|
+
### HIGH (Should Fix)
|
|
38
|
+
- Unnecessary `.clone()` to satisfy borrow checker
|
|
39
|
+
- `String` parameter where `&str` or `impl AsRef<str>` suffices
|
|
40
|
+
- Blocking in async context (`std::thread::sleep`, `std::fs`)
|
|
41
|
+
- Missing `Send`/`Sync` bounds on shared types
|
|
42
|
+
- Wildcard `_ =>` match on business-critical enums
|
|
43
|
+
- Large functions (>50 lines)
|
|
44
|
+
|
|
45
|
+
### MEDIUM (Consider)
|
|
46
|
+
- Unnecessary allocation in hot paths
|
|
47
|
+
- Missing `with_capacity` when size is known
|
|
48
|
+
- Suppressed clippy warnings without justification
|
|
49
|
+
- Public API without `///` documentation
|
|
50
|
+
- Consider `#[must_use]` on non-`must_use` return types where ignoring values is likely a bug
|
|
51
|
+
|
|
52
|
+
## Automated Checks Run
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Build gate (must pass before review)
|
|
56
|
+
cargo check
|
|
57
|
+
|
|
58
|
+
# Lints and suggestions
|
|
59
|
+
cargo clippy -- -D warnings
|
|
60
|
+
|
|
61
|
+
# Formatting
|
|
62
|
+
cargo fmt --check
|
|
63
|
+
|
|
64
|
+
# Tests
|
|
65
|
+
cargo test
|
|
66
|
+
|
|
67
|
+
# Security audit (if available)
|
|
68
|
+
if command -v cargo-audit >/dev/null; then cargo audit; else echo "cargo-audit not installed"; fi
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Example Usage
|
|
72
|
+
|
|
73
|
+
````text
|
|
74
|
+
User: /rust-review
|
|
75
|
+
|
|
76
|
+
Agent:
|
|
77
|
+
# Rust Code Review Report
|
|
78
|
+
|
|
79
|
+
## Files Reviewed
|
|
80
|
+
- src/service/user.rs (modified)
|
|
81
|
+
- src/handler/api.rs (modified)
|
|
82
|
+
|
|
83
|
+
## Static Analysis Results
|
|
84
|
+
- Build: Successful
|
|
85
|
+
- Clippy: No warnings
|
|
86
|
+
- Formatting: Passed
|
|
87
|
+
- Tests: All passing
|
|
88
|
+
|
|
89
|
+
## Issues Found
|
|
90
|
+
|
|
91
|
+
[CRITICAL] Unchecked unwrap in Production Path
|
|
92
|
+
File: src/service/user.rs:28
|
|
93
|
+
Issue: Using `.unwrap()` on database query result
|
|
94
|
+
```rust
|
|
95
|
+
let user = db.find_by_id(id).unwrap(); // Panics on missing user
|
|
96
|
+
```
|
|
97
|
+
Fix: Propagate error with context
|
|
98
|
+
```rust
|
|
99
|
+
let user = db.find_by_id(id)
|
|
100
|
+
.context("failed to fetch user")?;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
[HIGH] Unnecessary Clone
|
|
104
|
+
File: src/handler/api.rs:45
|
|
105
|
+
Issue: Cloning String to satisfy borrow checker
|
|
106
|
+
```rust
|
|
107
|
+
let name = user.name.clone();
|
|
108
|
+
process(&user, &name);
|
|
109
|
+
```
|
|
110
|
+
Fix: Restructure to avoid clone
|
|
111
|
+
```rust
|
|
112
|
+
let result = process_name(&user.name);
|
|
113
|
+
use_user(&user, result);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Summary
|
|
117
|
+
- CRITICAL: 1
|
|
118
|
+
- HIGH: 1
|
|
119
|
+
- MEDIUM: 0
|
|
120
|
+
|
|
121
|
+
Recommendation: Block merge until CRITICAL issue is fixed
|
|
122
|
+
````
|
|
123
|
+
|
|
124
|
+
## Approval Criteria
|
|
125
|
+
|
|
126
|
+
| Status | Condition |
|
|
127
|
+
|--------|-----------|
|
|
128
|
+
| Approve | No CRITICAL or HIGH issues |
|
|
129
|
+
| Warning | Only MEDIUM issues (merge with caution) |
|
|
130
|
+
| Block | CRITICAL or HIGH issues found |
|
|
131
|
+
|
|
132
|
+
## Integration with Other Commands
|
|
133
|
+
|
|
134
|
+
- Use `/rust-test` first to ensure tests pass
|
|
135
|
+
- Use `/rust-build` if build errors occur
|
|
136
|
+
- Use `/rust-review` before committing
|
|
137
|
+
- Use `/code-review` for non-Rust-specific concerns
|
|
138
|
+
|
|
139
|
+
## Related
|
|
140
|
+
|
|
141
|
+
- Agent: `agents/rust-reviewer.md`
|
|
142
|
+
- Skills: `skills/rust-patterns/`, `skills/rust-testing/`
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Enforce TDD workflow for Rust. Write tests first, then implement. Verify 80%+ coverage with cargo-llvm-cov.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Rust TDD Command
|
|
6
|
+
|
|
7
|
+
This command enforces test-driven development methodology for Rust code using `#[test]`, rstest, proptest, and mockall.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Define Types/Traits**: Scaffold function signatures with `todo!()`
|
|
12
|
+
2. **Write Tests**: Create comprehensive test module (RED)
|
|
13
|
+
3. **Run Tests**: Verify tests fail for the right reason
|
|
14
|
+
4. **Implement Code**: Write minimal code to pass (GREEN)
|
|
15
|
+
5. **Refactor**: Improve while keeping tests green
|
|
16
|
+
6. **Check Coverage**: Ensure 80%+ coverage with cargo-llvm-cov
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
Use `/rust-test` when:
|
|
21
|
+
- Implementing new Rust functions, methods, or traits
|
|
22
|
+
- Adding test coverage to existing Rust code
|
|
23
|
+
- Fixing bugs (write failing test first)
|
|
24
|
+
- Building critical business logic
|
|
25
|
+
- Learning TDD workflow in Rust
|
|
26
|
+
|
|
27
|
+
## TDD Cycle
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
RED -> Write failing test first
|
|
31
|
+
GREEN -> Implement minimal code to pass
|
|
32
|
+
REFACTOR -> Improve code, tests stay green
|
|
33
|
+
REPEAT -> Next test case
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Example Session
|
|
37
|
+
|
|
38
|
+
````text
|
|
39
|
+
User: /rust-test I need a function to validate user registration
|
|
40
|
+
|
|
41
|
+
Agent:
|
|
42
|
+
# TDD Session: Registration Validator
|
|
43
|
+
|
|
44
|
+
## Step 1: Define Interface
|
|
45
|
+
|
|
46
|
+
```rust
|
|
47
|
+
// src/validator.rs
|
|
48
|
+
pub struct RegistrationRequest {
|
|
49
|
+
pub name: String,
|
|
50
|
+
pub email: String,
|
|
51
|
+
pub password: String,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
pub enum ValidationResult {
|
|
55
|
+
Valid,
|
|
56
|
+
Invalid(Vec<String>),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
pub fn validate_registration(request: &RegistrationRequest) -> ValidationResult {
|
|
60
|
+
todo!()
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Step 2: Write Tests (RED)
|
|
65
|
+
|
|
66
|
+
```rust
|
|
67
|
+
#[cfg(test)]
|
|
68
|
+
mod tests {
|
|
69
|
+
use super::*;
|
|
70
|
+
|
|
71
|
+
#[test]
|
|
72
|
+
fn valid_registration_returns_valid() {
|
|
73
|
+
let request = RegistrationRequest {
|
|
74
|
+
name: "Alice".into(),
|
|
75
|
+
email: "alice@example.com".into(),
|
|
76
|
+
password: "SecureP@ss1".into(),
|
|
77
|
+
};
|
|
78
|
+
assert!(matches!(validate_registration(&request), ValidationResult::Valid));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#[test]
|
|
82
|
+
fn blank_name_returns_invalid() {
|
|
83
|
+
let request = RegistrationRequest {
|
|
84
|
+
name: "".into(),
|
|
85
|
+
email: "alice@example.com".into(),
|
|
86
|
+
password: "SecureP@ss1".into(),
|
|
87
|
+
};
|
|
88
|
+
match validate_registration(&request) {
|
|
89
|
+
ValidationResult::Invalid(errors) => {
|
|
90
|
+
assert!(errors.contains(&"Name is required".to_string()));
|
|
91
|
+
}
|
|
92
|
+
ValidationResult::Valid => panic!("expected Invalid"),
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#[test]
|
|
97
|
+
fn invalid_email_returns_invalid() {
|
|
98
|
+
let request = RegistrationRequest {
|
|
99
|
+
name: "Alice".into(),
|
|
100
|
+
email: "not-an-email".into(),
|
|
101
|
+
password: "SecureP@ss1".into(),
|
|
102
|
+
};
|
|
103
|
+
assert!(matches!(
|
|
104
|
+
validate_registration(&request),
|
|
105
|
+
ValidationResult::Invalid(_)
|
|
106
|
+
));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#[test]
|
|
110
|
+
fn short_password_returns_invalid() {
|
|
111
|
+
let request = RegistrationRequest {
|
|
112
|
+
name: "Alice".into(),
|
|
113
|
+
email: "alice@example.com".into(),
|
|
114
|
+
password: "short".into(),
|
|
115
|
+
};
|
|
116
|
+
assert!(matches!(
|
|
117
|
+
validate_registration(&request),
|
|
118
|
+
ValidationResult::Invalid(_)
|
|
119
|
+
));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Step 3: Run Tests — Verify FAIL
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
$ cargo test
|
|
128
|
+
running 4 tests
|
|
129
|
+
test tests::valid_registration_returns_valid ... FAILED (not yet implemented)
|
|
130
|
+
test tests::blank_name_returns_invalid ... FAILED
|
|
131
|
+
test tests::invalid_email_returns_invalid ... FAILED
|
|
132
|
+
test tests::short_password_returns_invalid ... FAILED
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Tests fail as expected (todo! panic).
|
|
136
|
+
|
|
137
|
+
## Step 4: Implement Minimal Code (GREEN)
|
|
138
|
+
|
|
139
|
+
```rust
|
|
140
|
+
pub fn validate_registration(request: &RegistrationRequest) -> ValidationResult {
|
|
141
|
+
let mut errors = Vec::new();
|
|
142
|
+
|
|
143
|
+
if request.name.trim().is_empty() {
|
|
144
|
+
errors.push("Name is required".into());
|
|
145
|
+
}
|
|
146
|
+
if !request.email.contains('@') {
|
|
147
|
+
errors.push("Invalid email format".into());
|
|
148
|
+
}
|
|
149
|
+
if request.password.len() < 8 {
|
|
150
|
+
errors.push("Password must be at least 8 characters".into());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if errors.is_empty() {
|
|
154
|
+
ValidationResult::Valid
|
|
155
|
+
} else {
|
|
156
|
+
ValidationResult::Invalid(errors)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Step 5: Run Tests — Verify PASS
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
$ cargo test
|
|
165
|
+
running 4 tests
|
|
166
|
+
test tests::valid_registration_returns_valid ... ok
|
|
167
|
+
test tests::blank_name_returns_invalid ... ok
|
|
168
|
+
test tests::invalid_email_returns_invalid ... ok
|
|
169
|
+
test tests::short_password_returns_invalid ... ok
|
|
170
|
+
|
|
171
|
+
test result: ok. 4 passed; 0 failed
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
All tests passing!
|
|
175
|
+
|
|
176
|
+
## Step 6: Check Coverage
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
$ cargo llvm-cov
|
|
180
|
+
Coverage: 100.0% of lines
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Coverage: 100%
|
|
184
|
+
|
|
185
|
+
## TDD Complete!
|
|
186
|
+
````
|
|
187
|
+
|
|
188
|
+
## Test Patterns
|
|
189
|
+
|
|
190
|
+
### Unit Tests
|
|
191
|
+
|
|
192
|
+
```rust
|
|
193
|
+
#[cfg(test)]
|
|
194
|
+
mod tests {
|
|
195
|
+
use super::*;
|
|
196
|
+
|
|
197
|
+
#[test]
|
|
198
|
+
fn adds_two_numbers() {
|
|
199
|
+
assert_eq!(add(2, 3), 5);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
#[test]
|
|
203
|
+
fn handles_error() -> Result<(), Box<dyn std::error::Error>> {
|
|
204
|
+
let result = parse_config(r#"port = 8080"#)?;
|
|
205
|
+
assert_eq!(result.port, 8080);
|
|
206
|
+
Ok(())
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Parameterized Tests with rstest
|
|
212
|
+
|
|
213
|
+
```rust
|
|
214
|
+
use rstest::{rstest, fixture};
|
|
215
|
+
|
|
216
|
+
#[rstest]
|
|
217
|
+
#[case("hello", 5)]
|
|
218
|
+
#[case("", 0)]
|
|
219
|
+
#[case("rust", 4)]
|
|
220
|
+
fn test_string_length(#[case] input: &str, #[case] expected: usize) {
|
|
221
|
+
assert_eq!(input.len(), expected);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Async Tests
|
|
226
|
+
|
|
227
|
+
```rust
|
|
228
|
+
#[tokio::test]
|
|
229
|
+
async fn fetches_data_successfully() {
|
|
230
|
+
let client = TestClient::new().await;
|
|
231
|
+
let result = client.get("/data").await;
|
|
232
|
+
assert!(result.is_ok());
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Property-Based Tests
|
|
237
|
+
|
|
238
|
+
```rust
|
|
239
|
+
use proptest::prelude::*;
|
|
240
|
+
|
|
241
|
+
proptest! {
|
|
242
|
+
#[test]
|
|
243
|
+
fn encode_decode_roundtrip(input in ".*") {
|
|
244
|
+
let encoded = encode(&input);
|
|
245
|
+
let decoded = decode(&encoded).unwrap();
|
|
246
|
+
assert_eq!(input, decoded);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Coverage Commands
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Summary report
|
|
255
|
+
cargo llvm-cov
|
|
256
|
+
|
|
257
|
+
# HTML report
|
|
258
|
+
cargo llvm-cov --html
|
|
259
|
+
|
|
260
|
+
# Fail if below threshold
|
|
261
|
+
cargo llvm-cov --fail-under-lines 80
|
|
262
|
+
|
|
263
|
+
# Run specific test
|
|
264
|
+
cargo test test_name
|
|
265
|
+
|
|
266
|
+
# Run with output
|
|
267
|
+
cargo test -- --nocapture
|
|
268
|
+
|
|
269
|
+
# Run without stopping on first failure
|
|
270
|
+
cargo test --no-fail-fast
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Coverage Targets
|
|
274
|
+
|
|
275
|
+
| Code Type | Target |
|
|
276
|
+
|-----------|--------|
|
|
277
|
+
| Critical business logic | 100% |
|
|
278
|
+
| Public API | 90%+ |
|
|
279
|
+
| General code | 80%+ |
|
|
280
|
+
| Generated / FFI bindings | Exclude |
|
|
281
|
+
|
|
282
|
+
## TDD Best Practices
|
|
283
|
+
|
|
284
|
+
**DO:**
|
|
285
|
+
- Write test FIRST, before any implementation
|
|
286
|
+
- Run tests after each change
|
|
287
|
+
- Use `assert_eq!` over `assert!` for better error messages
|
|
288
|
+
- Use `?` in tests that return `Result` for cleaner output
|
|
289
|
+
- Test behavior, not implementation
|
|
290
|
+
- Include edge cases (empty, boundary, error paths)
|
|
291
|
+
|
|
292
|
+
**DON'T:**
|
|
293
|
+
- Write implementation before tests
|
|
294
|
+
- Skip the RED phase
|
|
295
|
+
- Use `#[should_panic]` when `Result::is_err()` works
|
|
296
|
+
- Use `sleep()` in tests — use channels or `tokio::time::pause()`
|
|
297
|
+
- Mock everything — prefer integration tests when feasible
|
|
298
|
+
|
|
299
|
+
## Related Commands
|
|
300
|
+
|
|
301
|
+
- `/rust-build` - Fix build errors
|
|
302
|
+
- `/rust-review` - Review code after implementation
|
|
303
|
+
- `/verify` - Run full verification loop
|
|
304
|
+
|
|
305
|
+
## Related
|
|
306
|
+
|
|
307
|
+
- Skill: `skills/rust-testing/`
|
|
308
|
+
- Skill: `skills/rust-patterns/`
|