@the-bearded-bear/claude-craft 9.1.1 → 9.2.0-next.32ff465

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.
Files changed (121) hide show
  1. package/Dev/i18n/base/Rust/checklists/new-feature.md +108 -0
  2. package/Dev/i18n/base/Rust/checklists/pre-commit.md +118 -0
  3. package/Dev/i18n/base/Rust/checks/all.md +251 -0
  4. package/Dev/i18n/base/Rust/checks/architecture.md +182 -0
  5. package/Dev/i18n/base/Rust/checks/code-quality.md +174 -0
  6. package/Dev/i18n/base/Rust/checks/security.md +184 -0
  7. package/Dev/i18n/base/Rust/checks/testing.md +180 -0
  8. package/Dev/i18n/base/Rust/commands/check.md +28 -0
  9. package/Dev/i18n/base/Rust/rules/00-project-context.md.template +253 -0
  10. package/Dev/i18n/base/Rust/templates/app-error.md +182 -0
  11. package/Dev/i18n/base/Rust/templates/handler.md +255 -0
  12. package/Dev/i18n/base/Rust/templates/integration-test.md +193 -0
  13. package/Dev/i18n/base/Tauri/checklists/new-feature.md +88 -0
  14. package/Dev/i18n/base/Tauri/checklists/pre-commit.md +121 -0
  15. package/Dev/i18n/base/Tauri/checks/all.md +250 -0
  16. package/Dev/i18n/base/Tauri/checks/architecture.md +165 -0
  17. package/Dev/i18n/base/Tauri/checks/code-quality.md +157 -0
  18. package/Dev/i18n/base/Tauri/checks/security.md +186 -0
  19. package/Dev/i18n/base/Tauri/checks/testing.md +153 -0
  20. package/Dev/i18n/base/Tauri/commands/check.md +28 -0
  21. package/Dev/i18n/base/Tauri/rules/00-project-context.md.template +161 -0
  22. package/Dev/i18n/base/Tauri/rules/02-architecture-tauri.md +226 -0
  23. package/Dev/i18n/base/Tauri/rules/03-coding-standards.md +140 -0
  24. package/Dev/i18n/base/Tauri/rules/06-tooling.md +133 -0
  25. package/Dev/i18n/base/Tauri/rules/07-testing-tauri.md +170 -0
  26. package/Dev/i18n/base/Tauri/rules/08-quality-tools.md +158 -0
  27. package/Dev/i18n/base/Tauri/rules/11-security-tauri.md +198 -0
  28. package/Dev/i18n/base/Tauri/templates/capability.md +106 -0
  29. package/Dev/i18n/base/Tauri/templates/command.md +211 -0
  30. package/Dev/i18n/base/Tauri/templates/ipc-mock-test.md +188 -0
  31. package/Dev/i18n/de/Common/rules/12-context-management.md +3 -0
  32. package/Dev/i18n/de/Rust/CLAUDE.md.template +94 -0
  33. package/Dev/i18n/de/Rust/agents/rust-reviewer.md +577 -0
  34. package/Dev/i18n/de/Rust/checks/all.md +250 -0
  35. package/Dev/i18n/de/Rust/commands/check.md +28 -0
  36. package/Dev/i18n/de/Rust/rules/02-architecture-rust.md +387 -0
  37. package/Dev/i18n/de/Rust/rules/03-coding-standards.md +251 -0
  38. package/Dev/i18n/de/Rust/rules/06-tooling.md +293 -0
  39. package/Dev/i18n/de/Rust/rules/07-testing-rust.md +333 -0
  40. package/Dev/i18n/de/Rust/rules/08-quality-tools.md +253 -0
  41. package/Dev/i18n/de/Rust/rules/11-security-rust.md +420 -0
  42. package/Dev/i18n/de/Tauri/CLAUDE.md.template +99 -0
  43. package/Dev/i18n/de/Tauri/agents/tauri-reviewer.md +452 -0
  44. package/Dev/i18n/de/Tauri/checks/all.md +252 -0
  45. package/Dev/i18n/de/Tauri/commands/check.md +28 -0
  46. package/Dev/i18n/en/Common/rules/12-context-management.md +3 -0
  47. package/Dev/i18n/en/Rust/CLAUDE.md.template +94 -0
  48. package/Dev/i18n/en/Rust/agents/rust-reviewer.md +577 -0
  49. package/Dev/i18n/en/Rust/checks/all.md +249 -0
  50. package/Dev/i18n/en/Rust/commands/check.md +28 -0
  51. package/Dev/i18n/en/Rust/rules/02-architecture-rust.md +387 -0
  52. package/Dev/i18n/en/Rust/rules/03-coding-standards.md +251 -0
  53. package/Dev/i18n/en/Rust/rules/06-tooling.md +293 -0
  54. package/Dev/i18n/en/Rust/rules/07-testing-rust.md +333 -0
  55. package/Dev/i18n/en/Rust/rules/08-quality-tools.md +253 -0
  56. package/Dev/i18n/en/Rust/rules/11-security-rust.md +420 -0
  57. package/Dev/i18n/en/Tauri/CLAUDE.md.template +99 -0
  58. package/Dev/i18n/en/Tauri/agents/tauri-reviewer.md +452 -0
  59. package/Dev/i18n/en/Tauri/checks/all.md +251 -0
  60. package/Dev/i18n/en/Tauri/commands/check.md +28 -0
  61. package/Dev/i18n/es/Common/rules/12-context-management.md +3 -0
  62. package/Dev/i18n/es/Rust/CLAUDE.md.template +94 -0
  63. package/Dev/i18n/es/Rust/agents/rust-reviewer.md +577 -0
  64. package/Dev/i18n/es/Rust/checks/all.md +250 -0
  65. package/Dev/i18n/es/Rust/commands/check.md +28 -0
  66. package/Dev/i18n/es/Rust/rules/02-architecture-rust.md +387 -0
  67. package/Dev/i18n/es/Rust/rules/03-coding-standards.md +251 -0
  68. package/Dev/i18n/es/Rust/rules/06-tooling.md +293 -0
  69. package/Dev/i18n/es/Rust/rules/07-testing-rust.md +333 -0
  70. package/Dev/i18n/es/Rust/rules/08-quality-tools.md +253 -0
  71. package/Dev/i18n/es/Rust/rules/11-security-rust.md +420 -0
  72. package/Dev/i18n/es/Tauri/CLAUDE.md.template +99 -0
  73. package/Dev/i18n/es/Tauri/agents/tauri-reviewer.md +452 -0
  74. package/Dev/i18n/es/Tauri/checks/all.md +252 -0
  75. package/Dev/i18n/es/Tauri/commands/check.md +28 -0
  76. package/Dev/i18n/fr/Common/rules/12-context-management.md +3 -0
  77. package/Dev/i18n/fr/Rust/CLAUDE.md.template +94 -0
  78. package/Dev/i18n/fr/Rust/agents/rust-reviewer.md +577 -0
  79. package/Dev/i18n/fr/Rust/checks/all.md +249 -0
  80. package/Dev/i18n/fr/Rust/commands/check.md +28 -0
  81. package/Dev/i18n/fr/Rust/rules/02-architecture-rust.md +387 -0
  82. package/Dev/i18n/fr/Rust/rules/03-coding-standards.md +251 -0
  83. package/Dev/i18n/fr/Rust/rules/06-tooling.md +293 -0
  84. package/Dev/i18n/fr/Rust/rules/07-testing-rust.md +333 -0
  85. package/Dev/i18n/fr/Rust/rules/08-quality-tools.md +253 -0
  86. package/Dev/i18n/fr/Rust/rules/11-security-rust.md +420 -0
  87. package/Dev/i18n/fr/Tauri/CLAUDE.md.template +99 -0
  88. package/Dev/i18n/fr/Tauri/agents/tauri-reviewer.md +452 -0
  89. package/Dev/i18n/fr/Tauri/checks/all.md +251 -0
  90. package/Dev/i18n/fr/Tauri/commands/check.md +28 -0
  91. package/Dev/i18n/pt/Common/rules/12-context-management.md +3 -0
  92. package/Dev/i18n/pt/Rust/CLAUDE.md.template +94 -0
  93. package/Dev/i18n/pt/Rust/agents/rust-reviewer.md +577 -0
  94. package/Dev/i18n/pt/Rust/checks/all.md +249 -0
  95. package/Dev/i18n/pt/Rust/commands/check.md +28 -0
  96. package/Dev/i18n/pt/Rust/rules/02-architecture-rust.md +387 -0
  97. package/Dev/i18n/pt/Rust/rules/03-coding-standards.md +251 -0
  98. package/Dev/i18n/pt/Rust/rules/06-tooling.md +293 -0
  99. package/Dev/i18n/pt/Rust/rules/07-testing-rust.md +333 -0
  100. package/Dev/i18n/pt/Rust/rules/08-quality-tools.md +253 -0
  101. package/Dev/i18n/pt/Rust/rules/11-security-rust.md +420 -0
  102. package/Dev/i18n/pt/Tauri/CLAUDE.md.template +99 -0
  103. package/Dev/i18n/pt/Tauri/agents/tauri-reviewer.md +452 -0
  104. package/Dev/i18n/pt/Tauri/checks/all.md +251 -0
  105. package/Dev/i18n/pt/Tauri/commands/check.md +28 -0
  106. package/Dev/scripts/check-config.sh +1 -1
  107. package/Dev/scripts/install-from-config.sh +6 -0
  108. package/Dev/scripts/install-rust-rules.sh +139 -0
  109. package/Dev/scripts/install-tauri-rules.sh +149 -0
  110. package/Dev/stack-profiles/rust/permissions.txt +4 -0
  111. package/Dev/stack-profiles/rust/quality.md +3 -0
  112. package/Dev/stack-profiles/rust/stack.txt +2 -0
  113. package/Dev/stack-profiles/tauri/permissions.txt +7 -0
  114. package/Dev/stack-profiles/tauri/quality.md +4 -0
  115. package/Dev/stack-profiles/tauri/stack.txt +2 -0
  116. package/README.md +11 -5
  117. package/bundles/cursor/.cursorrules +5 -3
  118. package/bundles/windsurf/.windsurfrules +5 -3
  119. package/cli/lib/doctor.js +1 -1
  120. package/cli/lib/tech-registry.js +20 -0
  121. package/package.json +4 -7
@@ -0,0 +1,108 @@
1
+ # New Feature Development Checklist - Rust / Axum
2
+
3
+ ## Before Starting
4
+
5
+ - [ ] Feature discussed and validated with the team
6
+ - [ ] Acceptance criteria written (Given/When/Then)
7
+ - [ ] Assumptions stated explicitly (inputs, invariants, volume, authorization, latency budget)
8
+ - [ ] API contract defined if exposed (OpenAPI 3.x, error format RFC 9457)
9
+ - [ ] Database changes identified (tables, columns, indexes, constraints)
10
+ - [ ] Impact analysis done: crates touched, breaking changes, rollback plan
11
+ - [ ] Feature flag decided for risky changes
12
+
13
+ ## Development (TDD: Red, Green, Refactor)
14
+
15
+ ### Design (layers first)
16
+
17
+ - [ ] Start from the domain: types, invariants and errors before routes
18
+ - [ ] Ports (traits) added only for real boundaries: repository, clock, mailer, external API
19
+ - [ ] One use case = one function or struct with one public method
20
+ - [ ] No speculative traits, generics, options, or parameters (YAGNI)
21
+ - [ ] Domain crate still free of axum, sqlx and tokio dependencies
22
+
23
+ ### Domain Layer
24
+
25
+ - [ ] Newtypes validate on construction (`Email::parse`, `Quantity::new`); no primitive obsession
26
+ - [ ] States modeled as enums; illegal states unrepresentable where cheap
27
+ - [ ] Domain errors are a `thiserror` enum with one variant per failure the caller can act on
28
+ - [ ] No panics: fallible operations return `Result`
29
+
30
+ ### Database
31
+
32
+ - [ ] Migration created with `sqlx migrate add` and is safe on large tables
33
+ - [ ] Foreign keys, indexes, `NOT NULL`, `UNIQUE` and `CHECK` constraints mirror domain invariants
34
+ - [ ] Queries written with `query!` / `query_as!`; dynamic filters through `QueryBuilder::push_bind`
35
+ - [ ] `cargo sqlx prepare --workspace` run and `.sqlx/` committed
36
+ - [ ] Multi-statement writes inside a transaction; no transaction held across external calls
37
+
38
+ ### HTTP Layer
39
+
40
+ - [ ] Routes registered in the resource's `routes()` function; path syntax `/{id}` (axum 0.8)
41
+ - [ ] Handlers <= 15 lines: extract, validate, call the use case, map the result
42
+ - [ ] Request/response DTOs separate from domain types; `TryFrom<Dto>` builds validated domain values
43
+ - [ ] Authentication layer applied to the router; authorization checks the resource owner or tenant
44
+ - [ ] Rate limit added on sensitive endpoints (login, password reset, expensive operations)
45
+ - [ ] Errors flow through `AppError` and render RFC 9457 `application/problem+json`
46
+ - [ ] Correct statuses: 201 + `Location` on create, 204 on delete, 400/422 on validation, 404, 409, 403
47
+ - [ ] Body, timeout and CORS settings checked for the new route
48
+
49
+ ### Async and Background Work
50
+
51
+ - [ ] No blocking calls on the runtime; CPU-bound work through `spawn_blocking`
52
+ - [ ] No lock guard held across `.await`
53
+ - [ ] Work slower than ~200 ms moved to a background worker or queue; jobs idempotent with retry policy
54
+ - [ ] Spawned tasks tracked and cancellation-safe; graceful shutdown still drains them
55
+
56
+ ### Code Quality
57
+
58
+ - [ ] `cargo fmt` and `cargo clippy -D warnings` pass
59
+ - [ ] Borrowing preferred over cloning; iterators over index loops
60
+ - [ ] Naming explicit (RFC 430); comments explain WHY
61
+ - [ ] `tracing` spans/events added with structured fields; no secrets in logs
62
+
63
+ ## Testing
64
+
65
+ - [ ] Domain tests: valid and invalid construction, state transitions, boundaries
66
+ - [ ] Use case tests against in-memory fakes: success and each failure variant
67
+ - [ ] HTTP tests with `tower::ServiceExt::oneshot` for every new endpoint, including 401 and 403 cases
68
+ - [ ] Database tests with `#[sqlx::test]`; migrations applied per test
69
+ - [ ] Error mapping tested (status, `problem+json` body)
70
+ - [ ] Property tests (`proptest`) for parsers and validators when relevant
71
+ - [ ] Coverage stays >= 80%; time injected; external HTTP stubbed
72
+
73
+ ## Security
74
+
75
+ - [ ] `cargo audit` and `cargo deny check` clean
76
+ - [ ] No string-built SQL; no `unsafe` without `// SAFETY:` and tests
77
+ - [ ] IDOR checked: users cannot reach other users' or tenants' records
78
+ - [ ] Secrets in environment or secret store, wrapped in `SecretString`
79
+ - [ ] Input bounded (body size, collection sizes, pagination limits) and validated
80
+ - [ ] New logs do not contain sensitive data
81
+
82
+ ## Performance
83
+
84
+ - [ ] No N+1 queries; batch with `ANY($1)` or joins
85
+ - [ ] Pagination on list endpoints (keyset where the table is large)
86
+ - [ ] Indexes support new filters and sorts; `EXPLAIN` checked on heavy queries
87
+ - [ ] Pool size and timeouts reviewed for the new load
88
+
89
+ ## Documentation
90
+
91
+ - [ ] README or docs updated
92
+ - [ ] OpenAPI document updated
93
+ - [ ] ADR written for significant decisions
94
+ - [ ] CHANGELOG entry added; public items documented with `///`
95
+
96
+ ## Before Merge
97
+
98
+ - [ ] `./scripts/ci.sh` passes locally and in CI
99
+ - [ ] Self-review of the diff completed
100
+ - [ ] PR description explains the why, links the ticket, lists risks and rollback
101
+ - [ ] Reviewer approval received; squash merge with Conventional Commit title
102
+
103
+ ## Deployment
104
+
105
+ - [ ] Migrations run before the new binary starts (release step or startup migrate)
106
+ - [ ] Feature flag default set; rollback path verified
107
+ - [ ] Monitoring and alerts in place (error rate, latency, pool saturation)
108
+ - [ ] Smoke test after deploy (health endpoint and the main flow)
@@ -0,0 +1,118 @@
1
+ # Pre-Commit Checklist - Rust / Axum
2
+
3
+ ## Quick Validation Before Each Commit
4
+
5
+ All commands run in Docker (`docker compose exec app ...`). Keep one script or `make ci` target that chains the steps below so the local gate equals the CI gate.
6
+
7
+ ### Code Quality
8
+
9
+ - [ ] Formatting clean (`cargo fmt --all -- --check`)
10
+ - [ ] Clippy clean with warnings denied (`cargo clippy --workspace --all-targets --all-features -- -D warnings`)
11
+ - [ ] New `#[allow(...)]` justified, scoped to one item (prefer `#[expect(..., reason = "...")]`)
12
+ - [ ] No unused `use`, dead code, or commented-out code
13
+ - [ ] No `dbg!`, `println!`, `todo!` left behind
14
+ - [ ] Functions < 10 lines (limit 20), nesting <= 3, parameters <= 4
15
+
16
+ ### Tests
17
+
18
+ - [ ] All tests pass (`cargo nextest run --workspace --all-features`)
19
+ - [ ] Doc tests pass (`cargo test --workspace --doc`)
20
+ - [ ] New behavior has tests written first (Red, Green, Refactor)
21
+ - [ ] Bug fixes include a regression test that failed before the fix
22
+ - [ ] Coverage maintained at 80% or higher (`cargo llvm-cov nextest --workspace --fail-under-lines 80`)
23
+ - [ ] No `#[ignore]` added without a ticket
24
+
25
+ ### Security
26
+
27
+ - [ ] `cargo audit` reports no vulnerabilities
28
+ - [ ] `cargo deny check` passes (advisories, licenses, bans, sources)
29
+ - [ ] No hardcoded secrets; `.env` and key files not staged; secrets wrapped in `SecretString`
30
+ - [ ] `#![forbid(unsafe_code)]` still present; any new `unsafe` has a `// SAFETY:` comment and a test
31
+ - [ ] No `unwrap()` / `expect()` / indexing that can panic in request paths
32
+ - [ ] No string-built SQL (`format!` into a query); user input only bound as parameters
33
+ - [ ] New handlers authenticated, authorized per resource, and rate limited when they authenticate or send mail
34
+
35
+ ### Database
36
+
37
+ - [ ] Migration added with `sqlx migrate add`, has indexes and foreign keys
38
+ - [ ] No data backfill mixed into the schema migration
39
+ - [ ] `cargo sqlx prepare --workspace` run and `.sqlx/` committed (`cargo sqlx prepare --check` passes)
40
+ - [ ] Migrations apply cleanly on an empty database
41
+ - [ ] Multi-statement writes wrapped in a transaction; no N+1 query loops in handlers
42
+
43
+ ### Dependencies
44
+
45
+ - [ ] `Cargo.lock` committed and consistent (`cargo build --locked`)
46
+ - [ ] New crates justified (maintained, license allowed by `deny.toml`, no overlap with existing dependencies)
47
+ - [ ] Features trimmed (`default-features = false` where practical)
48
+
49
+ ### Documentation and Git
50
+
51
+ - [ ] README / docs updated when behavior or setup changed
52
+ - [ ] CHANGELOG updated if applicable
53
+ - [ ] Commit message follows Conventional Commits (`feat(orders): add refund endpoint`)
54
+ - [ ] Commit is atomic; branch up to date with `main`
55
+ - [ ] No unrelated files staged (`git status`, `git diff --staged`)
56
+
57
+ ## Automated Validation
58
+
59
+ ### CI gate script
60
+
61
+ ```bash
62
+ #!/usr/bin/env bash
63
+ # scripts/ci.sh - same steps locally and in CI
64
+ set -euo pipefail
65
+
66
+ cargo fmt --all -- --check
67
+ cargo clippy --workspace --all-targets --all-features -- -D warnings
68
+ cargo sqlx prepare --check --workspace
69
+ cargo nextest run --workspace --all-features
70
+ cargo test --workspace --doc
71
+ cargo deny check
72
+ cargo audit
73
+ ```
74
+
75
+ Run it in the container:
76
+
77
+ ```bash
78
+ docker compose exec app ./scripts/ci.sh
79
+ ```
80
+
81
+ ### Git pre-commit hook (Lefthook)
82
+
83
+ ```yaml
84
+ # lefthook.yml
85
+ pre-commit:
86
+ parallel: true
87
+ commands:
88
+ fmt:
89
+ glob: "*.rs"
90
+ run: docker compose exec -T app cargo fmt --all -- --check
91
+ clippy:
92
+ glob: "*.{rs,toml}"
93
+ run: docker compose exec -T app cargo clippy --workspace --all-targets -- -D warnings
94
+ pre-push:
95
+ commands:
96
+ tests:
97
+ run: docker compose exec -T app cargo nextest run --workspace
98
+ deny:
99
+ run: docker compose exec -T app cargo deny check
100
+ ```
101
+
102
+ Hooks are requirements, CLAUDE.md is a suggestion.
103
+
104
+ ## Quick Commands
105
+
106
+ ```bash
107
+ docker compose exec app cargo fmt --all
108
+ docker compose exec app cargo clippy --workspace --all-targets -- -D warnings
109
+ docker compose exec app cargo nextest run --workspace
110
+ docker compose exec app cargo llvm-cov nextest --workspace --summary-only
111
+ docker compose exec app cargo sqlx prepare --workspace
112
+ docker compose exec app cargo deny check
113
+ docker compose exec app cargo audit
114
+ ```
115
+
116
+ ## Final Check
117
+
118
+ If any box is unchecked, do not commit. Fix first, then re-run `./scripts/ci.sh`.
@@ -0,0 +1,251 @@
1
+ # Check Complete Rust / Axum Compliance
2
+
3
+ ## Arguments
4
+
5
+ $ARGUMENTS (optional: path to project to analyze)
6
+
7
+ ## Plan Mode
8
+
9
+ > Plan mode is activated automatically when the scope spans multiple crates or requires cross-cutting investigation.
10
+
11
+ ## MISSION
12
+
13
+ Perform a complete compliance audit of the Rust / Axum project by orchestrating the 4 major checks: Architecture, Code Quality, Tests, and Security. Produce a consolidated report with an overall score out of 100 points.
14
+
15
+ ### Step 1: Audit Preparation
16
+
17
+ Prepare audit environment:
18
+ - [ ] Identify project path to audit
19
+ - [ ] Verify presence of configuration files (`Cargo.toml`, `Cargo.lock`, `rust-toolchain.toml`, `deny.toml`, `rustfmt.toml`, `.sqlx/`)
20
+ - [ ] List main directories (`crates/` or `src/`, `migrations/`, `tests/`)
21
+ - [ ] Identify Rust toolchain, edition, and axum/tokio/sqlx versions
22
+
23
+ ```bash
24
+ docker compose exec app rustc --version
25
+ docker compose exec app cargo --version
26
+ docker compose exec app cargo tree --workspace --depth 1 -i axum
27
+ docker compose exec app grep -nE "^(edition|rust-version)" Cargo.toml
28
+ ```
29
+
30
+ **Note**: If $ARGUMENTS provided, use it as project path, otherwise use current directory.
31
+
32
+ ### Step 2: Architecture Audit (25 points)
33
+
34
+ Execute architecture check: `/rust:check architecture` or follow `.claude/references/rust/checks/architecture.md`
35
+
36
+ **Evaluated Criteria**:
37
+ - Workspace layout and project structure (5 pts)
38
+ - Thin HTTP layer: routers, extractors, state (6 pts)
39
+ - Domain and application design, dependency-free domain (6 pts)
40
+ - Data layer: SQLx checked queries, migrations, transactions (4 pts)
41
+ - Async runtime hygiene, graceful shutdown, observability (2 pts)
42
+ - Dependency direction and configuration (2 pts)
43
+
44
+ **Reference**: `.claude/references/rust/checks/architecture.md`
45
+
46
+ ### Step 3: Code Quality Audit (25 points)
47
+
48
+ Execute code quality check: `/rust:check code-quality` or follow `.claude/references/rust/checks/code-quality.md`
49
+
50
+ **Evaluated Criteria**:
51
+ - Clippy (`-D warnings`) and rustfmt clean (6 pts)
52
+ - Idiomatic Rust: borrowing, iterators, newtypes, no needless `unsafe` (5 pts)
53
+ - KISS/DRY/YAGNI and complexity (4 pts)
54
+ - Error handling: `thiserror`, `anyhow` only in binaries, no panics in request paths (4 pts)
55
+ - Naming conventions and documentation (3 pts)
56
+ - Toolchain pinning and CI (3 pts)
57
+
58
+ **Reference**: `.claude/references/rust/checks/code-quality.md`
59
+
60
+ ### Step 4: Testing Audit (25 points)
61
+
62
+ Execute testing check: `/rust:check testing` or follow `.claude/references/rust/checks/testing.md`
63
+
64
+ **Evaluated Criteria**:
65
+ - Code coverage with cargo-llvm-cov, 80% minimum (7 pts)
66
+ - Domain and unit tests (6 pts)
67
+ - HTTP and integration tests (`oneshot`, `#[sqlx::test]`) (5 pts)
68
+ - Contract, end-to-end and doc tests (3 pts)
69
+ - Fixtures and test data (2 pts)
70
+ - Test isolation and speed (cargo-nextest) (2 pts)
71
+
72
+ **Reference**: `.claude/references/rust/checks/testing.md`
73
+
74
+ ### Step 5: Security Audit (25 points)
75
+
76
+ Execute security check: `/rust:check security` or follow `.claude/references/rust/checks/security.md`
77
+
78
+ **Evaluated Criteria**:
79
+ - Memory safety and static analysis (`forbid(unsafe_code)`, clippy) (6 pts)
80
+ - Dependency vulnerabilities and supply chain (cargo-audit, cargo-deny) (4 pts)
81
+ - Secrets and credentials management (4 pts)
82
+ - Authentication and authorization (Argon2id, JWT pinning, IDOR) (4 pts)
83
+ - Injection and input validation (4 pts)
84
+ - Secure configuration, headers, rate limiting (3 pts)
85
+
86
+ **Reference**: `.claude/references/rust/checks/security.md`
87
+
88
+ ### Step 6: Consolidation and Global Scoring
89
+
90
+ - [ ] Sum the 4 scores (max 100 points)
91
+ - [ ] Identify critical categories (<50%)
92
+ - [ ] List all critical cross-cutting issues
93
+ - [ ] Prioritize actions by impact/effort
94
+ - [ ] Produce final consolidated report
95
+
96
+ **Grading Scale**:
97
+ - 90-100: Excellent - Reference project
98
+ - 75-89: Very Good - Some minor improvements
99
+ - 60-74: Acceptable - Requires improvements
100
+ - 40-59: Insufficient - Major refactoring required
101
+ - 0-39: Critical - Complete overhaul necessary
102
+
103
+ ### Step 7: Recommendations and Action Plan
104
+
105
+ - [ ] Identify top 3 priority actions across all categories
106
+ - [ ] Estimate effort (Low/Medium/High) and impact (Low/Medium/High) for each
107
+ - [ ] Propose implementation order
108
+ - [ ] Suggest quick wins (high impact/effort ratio)
109
+
110
+ **Version health** (reported in the executive summary, not scored):
111
+ - Rust stable is the baseline; flag a toolchain more than a few releases behind stable and an MSRV that blocks security updates.
112
+ - Edition 2024 is expected for new code; older editions are accepted with a migration plan (`cargo fix --edition`).
113
+ - axum 0.8, tokio 1.x and sqlx 0.9 are the reference lines; flag older minor lines and any yanked crate in `Cargo.lock`.
114
+
115
+ ## OUTPUT FORMAT
116
+
117
+ ```
118
+ RUST / AXUM COMPLIANCE AUDIT - COMPLETE REPORT
119
+ ==============================================
120
+
121
+ OVERALL SCORE: XX/100
122
+
123
+ COMPLIANCE LEVEL: [Excellent/Very Good/Acceptable/Insufficient/Critical]
124
+
125
+ Rust: X.Y.Z Edition: 20XX axum: X.Y Test runner: cargo-nextest
126
+
127
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
128
+
129
+ SCORES BY CATEGORY:
130
+
131
+ ARCHITECTURE : XX/25 [██████████░░░░░░░░░░] XX%
132
+ CODE QUALITY : XX/25 [██████████░░░░░░░░░░] XX%
133
+ TESTS : XX/25 [██████████░░░░░░░░░░] XX%
134
+ SECURITY : XX/25 [██████████░░░░░░░░░░] XX%
135
+
136
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
137
+
138
+ OVERALL STRENGTHS:
139
+ 1. [Strength identified in multiple categories]
140
+ 2. [Other major strength]
141
+ 3. [Third strength]
142
+
143
+ OVERALL IMPROVEMENTS:
144
+ 1. [Cross-cutting improvement]
145
+ 2. [Other recommended improvement]
146
+ 3. [Third improvement]
147
+
148
+ CRITICAL ISSUES:
149
+ 1. [Critical issue #1 - affected category]
150
+ 2. [Critical issue #2 - affected category]
151
+ 3. [Critical issue #3 - affected category]
152
+
153
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
154
+
155
+ DETAILS BY CATEGORY:
156
+
157
+ ┌─────────────────────────────────────────────┐
158
+ │ ARCHITECTURE (XX/25) │
159
+ └─────────────────────────────────────────────┘
160
+
161
+ Sub-scores:
162
+ • Workspace and structure : XX/5
163
+ • Thin HTTP layer : XX/6
164
+ • Domain / application design : XX/6
165
+ • Data layer : XX/4
166
+ • Async runtime / operations : XX/2
167
+ • Dependency direction : XX/2
168
+
169
+ Strengths:
170
+ - [Architecture strengths]
171
+
172
+ Issues:
173
+ - [Architecture issues]
174
+
175
+ [Similar sections for Code Quality, Tests, and Security...]
176
+
177
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
178
+
179
+ TOP 3 PRIORITY ACTIONS (ALL CATEGORIES):
180
+
181
+ 1. CRITICAL - [Action #1]
182
+ Category : [Architecture/Quality/Tests/Security]
183
+ Impact : [High/Medium/Low]
184
+ Effort : [High/Medium/Low]
185
+ Priority : IMMEDIATE
186
+
187
+ Detailed description:
188
+ [Explanation of problem and proposed solution]
189
+
190
+ Affected files:
191
+ - [file:line]
192
+
193
+ Correction example:
194
+ [Code or correction command]
195
+
196
+ 2. IMPORTANT - [Action #2]
197
+ [Same format...]
198
+
199
+ 3. RECOMMENDED - [Action #3]
200
+ [Same format...]
201
+
202
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
203
+
204
+ QUICK WINS (High Impact / Low Effort):
205
+
206
+ - [Quick win #1] - Category: [X] - Impact: [X] - Effort: [X]
207
+ - [Quick win #2] - Category: [X] - Impact: [X] - Effort: [X]
208
+ - [Quick win #3] - Category: [X] - Impact: [X] - Effort: [X]
209
+
210
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
211
+
212
+ RECOMMENDED ACTION PLAN:
213
+
214
+ WEEK 1 (Immediate):
215
+ - [ ] [Critical action #1]
216
+ - [ ] [Priority quick win]
217
+
218
+ WEEK 2-4 (Short term):
219
+ - [ ] [Important action #2]
220
+ - [ ] [Other quick wins]
221
+
222
+ MONTH 2-3 (Medium term):
223
+ - [ ] [Recommended action #3]
224
+ - [ ] [Progressive improvements]
225
+
226
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
227
+
228
+ EXECUTIVE SUMMARY:
229
+
230
+ [Summary paragraph on overall project state, major strengths,
231
+ major weaknesses, version health (toolchain, edition and key crate
232
+ lines), and recommended trajectory. Say whether the project is
233
+ production-ready, requires corrections, or needs refactoring.]
234
+
235
+ General Recommendation: [Production-ready / Minor corrections /
236
+ Major refactoring / Overhaul necessary]
237
+
238
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
239
+ ```
240
+
241
+ ## IMPORTANT NOTES
242
+
243
+ - This command orchestrates the 4 specialized audits
244
+ - Use Docker for all analysis tools (`docker compose exec app ...`)
245
+ - Provide concrete examples with file:line for each problem
246
+ - Prioritize actions based on Impact/Effort matrix
247
+ - Security problems are ALWAYS top priority
248
+ - A single-crate service with clean modules is acceptable; do not penalize the absence of a workspace on its own
249
+ - Propose automatable corrections (CI workflow, pre-commit hooks, `cargo deny`, `cargo clippy --fix` after review)
250
+ - Report must be actionable, not just descriptive
251
+ - Adapt recommendations to project business context
@@ -0,0 +1,182 @@
1
+ # Check Rust / Axum Architecture
2
+
3
+ ## Arguments
4
+
5
+ $ARGUMENTS (optional: path to project to analyze)
6
+
7
+ ## Plan Mode
8
+
9
+ > Plan mode is activated automatically when the scope spans multiple crates or requires cross-cutting investigation.
10
+
11
+ ## MISSION
12
+
13
+ Audit the architecture of the Rust web service (Rust stable, edition 2024, axum 0.8, tokio 1.x, sqlx 0.9). Stance: **layered or hexagonal, enforced by the crate graph**. The domain crate must not depend on axum, sqlx or tokio; the HTTP layer adapts requests to use cases and nothing more. A single crate with well-separated modules is acceptable for small services; do not demand a workspace the project does not need (YAGNI).
14
+
15
+ All commands run in Docker (`docker compose exec app ...`).
16
+
17
+ ### Step 1: Workspace and Project Structure (5 points)
18
+
19
+ ```bash
20
+ docker compose exec app cargo metadata --no-deps --format-version 1 | jq -r '.packages[].name'
21
+ docker compose exec app cargo tree --workspace --depth 1
22
+ docker compose exec app ls crates/ migrations/ .sqlx/
23
+ docker compose exec app grep -nE "edition|rust-version|resolver|\[workspace" Cargo.toml
24
+ ```
25
+
26
+ Checklist:
27
+ - [ ] Cargo workspace with one crate per layer (for example `domain`, `application`, `infrastructure`, `http`, plus a thin `app` binary), or a single crate with equivalent top-level modules
28
+ - [ ] `edition = "2024"` and `rust-version` (MSRV) declared; `resolver = "3"` or the edition default
29
+ - [ ] Shared dependency versions centralized in `[workspace.dependencies]`; shared lints in `[workspace.lints]`
30
+ - [ ] `Cargo.lock` committed for binaries; `rust-toolchain.toml` pins the channel
31
+ - [ ] The binary crate only wires dependencies (config, pool, router, server); no business code in `main.rs`
32
+ - [ ] SQL migrations in `migrations/` (sqlx-cli) and the offline query cache `.sqlx/` committed
33
+
34
+ Detect anti-patterns:
35
+
36
+ ```bash
37
+ # Giant files
38
+ docker compose exec app sh -c 'find crates src -name "*.rs" | xargs wc -l | sort -rn | head -10'
39
+ # Business code in main
40
+ docker compose exec app sh -c 'wc -l src/main.rs crates/*/src/main.rs'
41
+ ```
42
+
43
+ **Scoring**: 5 pts, minus 1 per violation (min 0).
44
+
45
+ ### Step 2: Thin HTTP Layer (6 points)
46
+
47
+ Handlers coordinate: extract, validate, call a use case, map the result to a response. No business rules, no SQL.
48
+
49
+ ```bash
50
+ docker compose exec app sh -c 'find crates src -path "*http*" -name "*.rs" | xargs wc -l | sort -rn | head -10'
51
+ # SQL or pool access inside handlers
52
+ docker compose exec app grep -rnE "sqlx::query|\.fetch_(one|all|optional)|\.execute\(" crates/http src/http src/handlers
53
+ # Panics in request paths
54
+ docker compose exec app grep -rnE "\.unwrap\(\)|\.expect\(|panic!|unreachable!|todo!|unimplemented!" crates/http src/http src/handlers
55
+ ```
56
+
57
+ Checklist:
58
+ - [ ] Handlers are <= 15 lines (target 10): extractors in, use case call, response out
59
+ - [ ] Router assembled in one function per resource (`fn routes() -> Router<AppState>`) and merged/nested in the app builder
60
+ - [ ] Path parameters use the 0.8 syntax (`/{id}`, `/{*rest}`), not the removed `/:id`
61
+ - [ ] Shared state is a cheap-to-clone `AppState` (`Arc` inside, or `Clone` handles such as `PgPool`) injected with `State<AppState>`; no global mutable statics
62
+ - [ ] Request/response DTOs are separate from domain types and database rows
63
+ - [ ] Validation at the boundary (`validator`, or `TryFrom<Dto>` building validated domain types); no `unwrap()`/`expect()` in request paths
64
+ - [ ] Cross-cutting concerns (tracing, timeout, CORS, body limit, auth) are Tower layers, not copy-pasted in handlers
65
+ - [ ] Custom extractors implement `FromRequestParts` / `FromRequest` without `#[async_trait]` (not needed in axum 0.8)
66
+
67
+ **Scoring**: 6 pts. Deduct 1 per handler with SQL or business rules, 1 per `unwrap`/`expect` cluster in request paths, max -6.
68
+
69
+ ### Step 3: Domain and Application Design (6 points)
70
+
71
+ ```bash
72
+ docker compose exec app cat crates/domain/Cargo.toml
73
+ docker compose exec app cargo tree -p domain --edges normal --depth 1
74
+ docker compose exec app grep -rnE "^use (axum|sqlx|tokio|tower|hyper)" crates/domain/src
75
+ docker compose exec app grep -rnE "(pub )?trait \w+" crates/application/src crates/domain/src
76
+ ```
77
+
78
+ Checklist:
79
+ - [ ] The domain crate has no dependency on axum, sqlx, tokio or tower
80
+ - [ ] Invariants live in types: newtypes (`Email`, `UserId`) validated in constructors; enums for states instead of strings or booleans
81
+ - [ ] Ports (repository, clock, mailer traits) are defined in domain/application; adapters live in infrastructure
82
+ - [ ] Use cases are plain async functions or structs with a single public method; dependencies injected through constructors or generics
83
+ - [ ] Trait objects (`dyn`) used only where runtime polymorphism is needed; generics preferred otherwise
84
+ - [ ] Domain errors are explicit enums (`thiserror`), not `anyhow::Error`
85
+ - [ ] Illegal states are unrepresentable (typestate or enums) where cheap
86
+ - [ ] No God types: a struct named `Manager`, `Service` or `Utils` with many unrelated methods is a smell
87
+
88
+ **Scoring**: 6 pts. Deduct 2 if the domain depends on axum/sqlx, 1 per use case mixing HTTP or SQL concerns, 1 per god type.
89
+
90
+ ### Step 4: Data Layer (4 points)
91
+
92
+ ```bash
93
+ docker compose exec app grep -rnE "query!|query_as!|query_scalar!" crates src | wc -l
94
+ docker compose exec app grep -rnE "format!\(.*(SELECT|INSERT|UPDATE|DELETE)" crates src
95
+ docker compose exec app cargo sqlx prepare --check --workspace
96
+ docker compose exec app sqlx migrate info
97
+ docker compose exec app grep -rnE "PgPoolOptions|max_connections|acquire_timeout" crates src
98
+ ```
99
+
100
+ Checklist:
101
+ - [ ] Queries use `query!` / `query_as!` (compile-time checked) with the offline cache; `cargo sqlx prepare --check` passes in CI
102
+ - [ ] SQL is never built by string concatenation or `format!`; dynamic filters use `sqlx::QueryBuilder` with `push_bind`
103
+ - [ ] Every foreign key has an index and a database constraint; `NOT NULL`, `UNIQUE` and `CHECK` mirror domain invariants
104
+ - [ ] Migrations are forward-only and safe on large tables (concurrent index, backfill in a separate step)
105
+ - [ ] One `PgPool` created at startup with explicit `max_connections` and `acquire_timeout`; migrations run at startup or as a deploy step
106
+ - [ ] Multi-statement writes use a transaction (`pool.begin()`), committed explicitly; no transaction held across external calls
107
+ - [ ] Repositories return domain types, not `sqlx::Row`; row structs stay in infrastructure
108
+
109
+ **Scoring**: 4 pts, minus 1 per failed group above (checked queries, schema integrity, pool and migrations, transactions).
110
+
111
+ ### Step 5: Async Runtime and Operations (2 points)
112
+
113
+ ```bash
114
+ docker compose exec app grep -rnE "std::thread::sleep|std::fs::|reqwest::blocking" crates src
115
+ docker compose exec app grep -rnE "spawn_blocking|tokio::spawn|JoinSet" crates src
116
+ docker compose exec app grep -rnE "with_graceful_shutdown|ctrl_c|SignalKind" crates src
117
+ docker compose exec app grep -rnE "TraceLayer|TimeoutLayer|tracing_subscriber" crates src
118
+ ```
119
+
120
+ Checklist:
121
+ - [ ] No blocking calls on the async runtime; CPU-bound or blocking work goes through `tokio::task::spawn_blocking`
122
+ - [ ] No `std::sync::Mutex` guard held across an `.await`
123
+ - [ ] Graceful shutdown: `axum::serve(listener, app).with_graceful_shutdown(signal)` handling Ctrl+C and SIGTERM
124
+ - [ ] Spawned tasks are tracked (`JoinSet`, handles) and their errors observed; no fire-and-forget panics
125
+ - [ ] Health endpoints for liveness and readiness (database reachable)
126
+ - [ ] Structured logs through `tracing` with request ids (`TraceLayer`); subscriber initialized once in `main`
127
+
128
+ **Scoring**: 2 pts (1 for runtime hygiene, 1 for shutdown and observability).
129
+
130
+ ### Step 6: Dependency Direction and Features (2 points)
131
+
132
+ ```bash
133
+ docker compose exec app cargo tree --workspace --duplicates | head -30
134
+ docker compose exec app cargo tree -i axum --workspace
135
+ docker compose exec app grep -rnE "std::env::var|dotenv" crates src
136
+ ```
137
+
138
+ Checklist:
139
+ - [ ] Dependencies point inward: http and infrastructure depend on application and domain, never the reverse; no cycles
140
+ - [ ] Feature flags of heavy crates are trimmed (`default-features = false` where practical)
141
+ - [ ] Configuration parsed once at startup into a typed struct; `std::env::var` is not scattered through the code
142
+ - [ ] Duplicated major versions of the same crate are reviewed
143
+
144
+ **Scoring**: 2 pts (1 for dependency direction, 1 for configuration and dependency hygiene).
145
+
146
+ ## OUTPUT FORMAT
147
+
148
+ ```
149
+ RUST / AXUM ARCHITECTURE AUDIT
150
+ ==============================
151
+
152
+ SCORE: XX/25
153
+
154
+ Rust: X.Y.Z Edition: 20XX axum: X.Y Crates: N Handlers: N
155
+
156
+ SUB-SCORES:
157
+ Workspace and structure : XX/5
158
+ Thin HTTP layer : XX/6
159
+ Domain / application design : XX/6
160
+ Data layer : XX/4
161
+ Async runtime / operations : XX/2
162
+ Dependency direction : XX/2
163
+
164
+ STRENGTHS:
165
+ - [...]
166
+
167
+ ISSUES (by severity):
168
+ - CRITICAL: [file:line] [description] -> [fix]
169
+ - IMPORTANT: ...
170
+ - MINOR: ...
171
+
172
+ RECOMMENDATIONS:
173
+ 1. [Action] (effort: Low/Medium/High, impact: Low/Medium/High)
174
+ 2. ...
175
+ ```
176
+
177
+ ## IMPORTANT NOTES
178
+
179
+ - Findings must cite `file:line` and propose a concrete refactoring (for example "move the pricing rule from `create_order` into `Order::place` in the domain crate")
180
+ - Do not recommend new crates or traits when the code is small and readable (YAGNI); one implementation does not need a trait until a second one or a test double exists
181
+ - A single-crate service with clean modules scores fully on layering if the dependency direction holds
182
+ - Never run destructive tasks (`sqlx database drop`, `sqlx migrate revert`) during an audit