@the-bearded-bear/claude-craft 9.1.1 → 9.2.0-next.09b0d75

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 (170) hide show
  1. package/Dev/i18n/base/Common/hooks/scripts/guard-network.sh +64 -0
  2. package/Dev/i18n/base/Common/hooks/scripts/lib/hook-io.sh +90 -0
  3. package/Dev/i18n/base/Common/hooks/scripts/output-size-hint.sh +19 -0
  4. package/Dev/i18n/base/Common/hooks/scripts/protect-sensitive-files.sh +16 -0
  5. package/Dev/i18n/base/Rust/checklists/new-feature.md +108 -0
  6. package/Dev/i18n/base/Rust/checklists/pre-commit.md +118 -0
  7. package/Dev/i18n/base/Rust/checks/all.md +251 -0
  8. package/Dev/i18n/base/Rust/checks/architecture.md +182 -0
  9. package/Dev/i18n/base/Rust/checks/code-quality.md +174 -0
  10. package/Dev/i18n/base/Rust/checks/security.md +184 -0
  11. package/Dev/i18n/base/Rust/checks/testing.md +180 -0
  12. package/Dev/i18n/base/Rust/commands/check.md +28 -0
  13. package/Dev/i18n/base/Rust/rules/00-project-context.md.template +253 -0
  14. package/Dev/i18n/base/Rust/templates/app-error.md +182 -0
  15. package/Dev/i18n/base/Rust/templates/handler.md +255 -0
  16. package/Dev/i18n/base/Rust/templates/integration-test.md +193 -0
  17. package/Dev/i18n/base/Tauri/checklists/new-feature.md +88 -0
  18. package/Dev/i18n/base/Tauri/checklists/pre-commit.md +121 -0
  19. package/Dev/i18n/base/Tauri/checks/all.md +250 -0
  20. package/Dev/i18n/base/Tauri/checks/architecture.md +165 -0
  21. package/Dev/i18n/base/Tauri/checks/code-quality.md +157 -0
  22. package/Dev/i18n/base/Tauri/checks/security.md +186 -0
  23. package/Dev/i18n/base/Tauri/checks/testing.md +153 -0
  24. package/Dev/i18n/base/Tauri/commands/check.md +28 -0
  25. package/Dev/i18n/base/Tauri/rules/00-project-context.md.template +161 -0
  26. package/Dev/i18n/base/Tauri/rules/02-architecture-tauri.md +226 -0
  27. package/Dev/i18n/base/Tauri/rules/03-coding-standards.md +140 -0
  28. package/Dev/i18n/base/Tauri/rules/06-tooling.md +133 -0
  29. package/Dev/i18n/base/Tauri/rules/07-testing-tauri.md +170 -0
  30. package/Dev/i18n/base/Tauri/rules/08-quality-tools.md +158 -0
  31. package/Dev/i18n/base/Tauri/rules/11-security-tauri.md +198 -0
  32. package/Dev/i18n/base/Tauri/templates/capability.md +106 -0
  33. package/Dev/i18n/base/Tauri/templates/command.md +211 -0
  34. package/Dev/i18n/base/Tauri/templates/ipc-mock-test.md +188 -0
  35. package/Dev/i18n/base/WordPress/checklists/new-feature.md +59 -0
  36. package/Dev/i18n/base/WordPress/checklists/pre-commit.md +125 -0
  37. package/Dev/i18n/base/WordPress/checks/all.md +257 -0
  38. package/Dev/i18n/base/WordPress/checks/architecture.md +157 -0
  39. package/Dev/i18n/base/WordPress/checks/code-quality.md +158 -0
  40. package/Dev/i18n/base/WordPress/checks/security.md +158 -0
  41. package/Dev/i18n/base/WordPress/checks/testing.md +157 -0
  42. package/Dev/i18n/base/WordPress/commands/check.md +28 -0
  43. package/Dev/i18n/base/WordPress/rules/00-project-context.md.template +169 -0
  44. package/Dev/i18n/base/WordPress/rules/02-architecture-wordpress.md +172 -0
  45. package/Dev/i18n/base/WordPress/rules/03-coding-standards.md +98 -0
  46. package/Dev/i18n/base/WordPress/rules/06-tooling.md +146 -0
  47. package/Dev/i18n/base/WordPress/rules/07-testing-wordpress.md +150 -0
  48. package/Dev/i18n/base/WordPress/rules/08-quality-tools.md +161 -0
  49. package/Dev/i18n/base/WordPress/rules/11-security-wordpress.md +174 -0
  50. package/Dev/i18n/base/WordPress/skills/woocommerce/REFERENCE.md +214 -0
  51. package/Dev/i18n/base/WordPress/skills/woocommerce/SKILL.md +40 -0
  52. package/Dev/i18n/base/WordPress/skills/woocommerce/checklist.md +66 -0
  53. package/Dev/i18n/base/WordPress/templates/block.md +235 -0
  54. package/Dev/i18n/base/WordPress/templates/plugin-bootstrap.md +215 -0
  55. package/Dev/i18n/base/WordPress/templates/rest-endpoint.md +246 -0
  56. package/Dev/i18n/de/Common/rules/12-context-management.md +3 -0
  57. package/Dev/i18n/de/Rust/CLAUDE.md.template +94 -0
  58. package/Dev/i18n/de/Rust/agents/rust-reviewer.md +577 -0
  59. package/Dev/i18n/de/Rust/checks/all.md +250 -0
  60. package/Dev/i18n/de/Rust/commands/check.md +28 -0
  61. package/Dev/i18n/de/Rust/rules/02-architecture-rust.md +387 -0
  62. package/Dev/i18n/de/Rust/rules/03-coding-standards.md +251 -0
  63. package/Dev/i18n/de/Rust/rules/06-tooling.md +293 -0
  64. package/Dev/i18n/de/Rust/rules/07-testing-rust.md +333 -0
  65. package/Dev/i18n/de/Rust/rules/08-quality-tools.md +253 -0
  66. package/Dev/i18n/de/Rust/rules/11-security-rust.md +420 -0
  67. package/Dev/i18n/de/Tauri/CLAUDE.md.template +99 -0
  68. package/Dev/i18n/de/Tauri/agents/tauri-reviewer.md +452 -0
  69. package/Dev/i18n/de/Tauri/checks/all.md +252 -0
  70. package/Dev/i18n/de/Tauri/commands/check.md +28 -0
  71. package/Dev/i18n/de/WordPress/CLAUDE.md.template +100 -0
  72. package/Dev/i18n/de/WordPress/agents/wordpress-reviewer.md +348 -0
  73. package/Dev/i18n/de/WordPress/checks/all.md +242 -0
  74. package/Dev/i18n/de/WordPress/commands/check.md +28 -0
  75. package/Dev/i18n/en/Common/rules/12-context-management.md +3 -0
  76. package/Dev/i18n/en/Rust/CLAUDE.md.template +94 -0
  77. package/Dev/i18n/en/Rust/agents/rust-reviewer.md +577 -0
  78. package/Dev/i18n/en/Rust/checks/all.md +249 -0
  79. package/Dev/i18n/en/Rust/commands/check.md +28 -0
  80. package/Dev/i18n/en/Rust/rules/02-architecture-rust.md +387 -0
  81. package/Dev/i18n/en/Rust/rules/03-coding-standards.md +251 -0
  82. package/Dev/i18n/en/Rust/rules/06-tooling.md +293 -0
  83. package/Dev/i18n/en/Rust/rules/07-testing-rust.md +333 -0
  84. package/Dev/i18n/en/Rust/rules/08-quality-tools.md +253 -0
  85. package/Dev/i18n/en/Rust/rules/11-security-rust.md +420 -0
  86. package/Dev/i18n/en/Tauri/CLAUDE.md.template +99 -0
  87. package/Dev/i18n/en/Tauri/agents/tauri-reviewer.md +452 -0
  88. package/Dev/i18n/en/Tauri/checks/all.md +251 -0
  89. package/Dev/i18n/en/Tauri/commands/check.md +28 -0
  90. package/Dev/i18n/en/WordPress/CLAUDE.md.template +100 -0
  91. package/Dev/i18n/en/WordPress/agents/wordpress-reviewer.md +348 -0
  92. package/Dev/i18n/en/WordPress/checks/all.md +241 -0
  93. package/Dev/i18n/en/WordPress/commands/check.md +28 -0
  94. package/Dev/i18n/es/Common/rules/12-context-management.md +3 -0
  95. package/Dev/i18n/es/Rust/CLAUDE.md.template +94 -0
  96. package/Dev/i18n/es/Rust/agents/rust-reviewer.md +577 -0
  97. package/Dev/i18n/es/Rust/checks/all.md +250 -0
  98. package/Dev/i18n/es/Rust/commands/check.md +28 -0
  99. package/Dev/i18n/es/Rust/rules/02-architecture-rust.md +387 -0
  100. package/Dev/i18n/es/Rust/rules/03-coding-standards.md +251 -0
  101. package/Dev/i18n/es/Rust/rules/06-tooling.md +293 -0
  102. package/Dev/i18n/es/Rust/rules/07-testing-rust.md +333 -0
  103. package/Dev/i18n/es/Rust/rules/08-quality-tools.md +253 -0
  104. package/Dev/i18n/es/Rust/rules/11-security-rust.md +420 -0
  105. package/Dev/i18n/es/Tauri/CLAUDE.md.template +99 -0
  106. package/Dev/i18n/es/Tauri/agents/tauri-reviewer.md +452 -0
  107. package/Dev/i18n/es/Tauri/checks/all.md +252 -0
  108. package/Dev/i18n/es/Tauri/commands/check.md +28 -0
  109. package/Dev/i18n/es/WordPress/CLAUDE.md.template +100 -0
  110. package/Dev/i18n/es/WordPress/agents/wordpress-reviewer.md +348 -0
  111. package/Dev/i18n/es/WordPress/checks/all.md +241 -0
  112. package/Dev/i18n/es/WordPress/commands/check.md +28 -0
  113. package/Dev/i18n/fr/Common/rules/12-context-management.md +3 -0
  114. package/Dev/i18n/fr/Rust/CLAUDE.md.template +94 -0
  115. package/Dev/i18n/fr/Rust/agents/rust-reviewer.md +577 -0
  116. package/Dev/i18n/fr/Rust/checks/all.md +249 -0
  117. package/Dev/i18n/fr/Rust/commands/check.md +28 -0
  118. package/Dev/i18n/fr/Rust/rules/02-architecture-rust.md +387 -0
  119. package/Dev/i18n/fr/Rust/rules/03-coding-standards.md +251 -0
  120. package/Dev/i18n/fr/Rust/rules/06-tooling.md +293 -0
  121. package/Dev/i18n/fr/Rust/rules/07-testing-rust.md +333 -0
  122. package/Dev/i18n/fr/Rust/rules/08-quality-tools.md +253 -0
  123. package/Dev/i18n/fr/Rust/rules/11-security-rust.md +420 -0
  124. package/Dev/i18n/fr/Tauri/CLAUDE.md.template +99 -0
  125. package/Dev/i18n/fr/Tauri/agents/tauri-reviewer.md +452 -0
  126. package/Dev/i18n/fr/Tauri/checks/all.md +251 -0
  127. package/Dev/i18n/fr/Tauri/commands/check.md +28 -0
  128. package/Dev/i18n/fr/WordPress/CLAUDE.md.template +100 -0
  129. package/Dev/i18n/fr/WordPress/agents/wordpress-reviewer.md +348 -0
  130. package/Dev/i18n/fr/WordPress/checks/all.md +242 -0
  131. package/Dev/i18n/fr/WordPress/commands/check.md +28 -0
  132. package/Dev/i18n/pt/Common/rules/12-context-management.md +3 -0
  133. package/Dev/i18n/pt/Rust/CLAUDE.md.template +94 -0
  134. package/Dev/i18n/pt/Rust/agents/rust-reviewer.md +577 -0
  135. package/Dev/i18n/pt/Rust/checks/all.md +249 -0
  136. package/Dev/i18n/pt/Rust/commands/check.md +28 -0
  137. package/Dev/i18n/pt/Rust/rules/02-architecture-rust.md +387 -0
  138. package/Dev/i18n/pt/Rust/rules/03-coding-standards.md +251 -0
  139. package/Dev/i18n/pt/Rust/rules/06-tooling.md +293 -0
  140. package/Dev/i18n/pt/Rust/rules/07-testing-rust.md +333 -0
  141. package/Dev/i18n/pt/Rust/rules/08-quality-tools.md +253 -0
  142. package/Dev/i18n/pt/Rust/rules/11-security-rust.md +420 -0
  143. package/Dev/i18n/pt/Tauri/CLAUDE.md.template +99 -0
  144. package/Dev/i18n/pt/Tauri/agents/tauri-reviewer.md +452 -0
  145. package/Dev/i18n/pt/Tauri/checks/all.md +251 -0
  146. package/Dev/i18n/pt/Tauri/commands/check.md +28 -0
  147. package/Dev/i18n/pt/WordPress/CLAUDE.md.template +100 -0
  148. package/Dev/i18n/pt/WordPress/agents/wordpress-reviewer.md +348 -0
  149. package/Dev/i18n/pt/WordPress/checks/all.md +241 -0
  150. package/Dev/i18n/pt/WordPress/commands/check.md +28 -0
  151. package/Dev/scripts/check-config.sh +1 -1
  152. package/Dev/scripts/install-from-config.sh +9 -0
  153. package/Dev/scripts/install-rust-rules.sh +139 -0
  154. package/Dev/scripts/install-tauri-rules.sh +149 -0
  155. package/Dev/scripts/install-wordpress-rules.sh +153 -0
  156. package/Dev/stack-profiles/rust/permissions.txt +4 -0
  157. package/Dev/stack-profiles/rust/quality.md +3 -0
  158. package/Dev/stack-profiles/rust/stack.txt +2 -0
  159. package/Dev/stack-profiles/tauri/permissions.txt +7 -0
  160. package/Dev/stack-profiles/tauri/quality.md +4 -0
  161. package/Dev/stack-profiles/tauri/stack.txt +2 -0
  162. package/Dev/stack-profiles/wordpress/permissions.txt +10 -0
  163. package/Dev/stack-profiles/wordpress/quality.md +4 -0
  164. package/Dev/stack-profiles/wordpress/stack.txt +2 -0
  165. package/README.md +14 -5
  166. package/bundles/cursor/.cursorrules +6 -3
  167. package/bundles/windsurf/.windsurfrules +6 -3
  168. package/cli/lib/doctor.js +1 -1
  169. package/cli/lib/tech-registry.js +30 -0
  170. package/package.json +4 -7
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env bash
2
+ # PreToolUse(Bash) : bloque l'exécution directe d'un script téléchargé.
3
+ # 1. interpréteur nourri par une substitution : bash <(curl …), sh -c "$(curl …)", eval
4
+ # 2. téléchargement suivi d'un interpréteur dans le même pipeline : curl … | [sudo] sh
5
+ # 3. interpréteur lancé sur un fichier qui vient d'être téléchargé : curl -O …/i.sh && bash i.sh
6
+ # Les commandes ne sont reconnues qu'en position de commande (après sudo/env/VAR=…),
7
+ # donc `2>/dev/null`, `grep -o`, un domaine `.pl` ou un message de commit ne comptent pas.
8
+ # Télécharger un fichier (`curl -o`) reste du ressort des permissions, pas de ce hook.
9
+ set -u
10
+ # shellcheck source=lib/hook-io.sh
11
+ . "$(dirname "${BASH_SOURCE[0]}")/lib/hook-io.sh"
12
+
13
+ hook_require_parser
14
+ hook_input
15
+ CMD=$(hook_get tool_input.command)
16
+ [ -n "$CMD" ] || exit 0
17
+
18
+ # Corps de heredoc retirés (données), quotes neutralisées (sh -c 'curl … | sh' reste
19
+ # analysé), `<(curl` / `$(curl` marqués __DLSUB__ dans l'étage qui les reçoit, puis
20
+ # instructions séparées sur ; && || & ( ) ` { } et étages sur |.
21
+ verdict=$(printf '%s\n' "$CMD" | hook_strip_heredocs | tr "'\"" ' ' | awk '
22
+ function base(t) { sub(/[?#].*$/, "", t); sub(/.*\//, "", t); return t }
23
+ function is_interp(c) {
24
+ return c == "." || c ~ /^(sh|bash|zsh|dash|ksh|fish|python[0-9.]*|perl|ruby|node|deno|bun|php|pwsh|source|eval)$/
25
+ }
26
+ { buf = buf $0 ";" }
27
+ END {
28
+ gsub(/\|\|/, ";", buf); gsub(/&&/, ";", buf)
29
+ gsub(/[<$]\([ \t]*(curl|wget)[ \t]/, " __DLSUB__ ; curl ", buf)
30
+ ns = split(buf, stmts, /[;&()`{}]/)
31
+ for (s = 1; s <= ns; s++) {
32
+ piped = 0
33
+ np = split(stmts[s], stages, /\|/)
34
+ for (k = 1; k <= np; k++) {
35
+ nt = split(stages[k], t); i = 1; pre = 0; first = ""
36
+ while (i <= nt) {
37
+ if (t[i] ~ /^(sudo|doas|env|nohup|command|exec|time|nice|xargs)$/) { pre = 1; i++; continue }
38
+ if (pre && t[i] ~ /^-/) { i++; continue }
39
+ if (t[i] ~ /^[A-Za-z_][A-Za-z0-9_]*=/) { i++; continue }
40
+ if (first == "") first = base(t[i])
41
+ if (base(t[i]) ~ /^(sh|bash|zsh|dash|ksh)$/ && i < nt && t[i + 1] ~ /^-[a-z]*c$/) { i += 2; pre = 0; continue }
42
+ break
43
+ }
44
+ if (is_interp(first)) for (j = 1; j <= nt; j++) if (t[j] == "__DLSUB__") { print "sub"; exit }
45
+ if (i > nt) continue
46
+ cmd = base(t[i])
47
+ if (cmd == "curl" || cmd == "wget") {
48
+ piped = 1
49
+ for (j = i + 1; j <= nt; j++) if (t[j] !~ /^-/ && base(t[j]) != "") dl[base(t[j])] = 1
50
+ continue
51
+ }
52
+ if (!is_interp(cmd)) continue
53
+ if (piped) { print "pipe"; exit }
54
+ for (j = i + 1; j <= nt; j++) if (t[j] !~ /^-/) { if (base(t[j]) in dl) { print "file"; exit } break }
55
+ }
56
+ }
57
+ }')
58
+
59
+ case "$verdict" in
60
+ sub) hook_block "Feeding a download into an interpreter is not allowed" ;;
61
+ pipe) hook_block "Piping a download into an interpreter is not allowed" ;;
62
+ file) hook_block "Executing a freshly downloaded script is not allowed" ;;
63
+ esac
64
+ exit 0
@@ -0,0 +1,90 @@
1
+ # shellcheck shell=bash
2
+ # Bibliothèque commune des hooks Claude Code (sourcée, jamais exécutée).
3
+ #
4
+ # Contrat Claude Code : payload JSON sur stdin ; exit 2 + stderr = blocage ;
5
+ # seul hookSpecificOutput.additionalContext atteint le modèle (systemMessage = UI).
6
+ # jq est utilisé s'il est présent, sinon node (toujours là pour claude-craft).
7
+
8
+ HOOK_INPUT=""
9
+
10
+ hook_input() { HOOK_INPUT=$(cat); }
11
+
12
+ hook_has_jq() { command -v jq >/dev/null 2>&1; }
13
+
14
+ hook_has_parser() { hook_has_jq || command -v node >/dev/null 2>&1; }
15
+
16
+ # Valeur au chemin pointé (`tool_input.command`) ; objet/tableau => JSON compact.
17
+ hook_get() {
18
+ if hook_has_jq; then
19
+ printf '%s' "$HOOK_INPUT" | jq -r --arg p "$1" \
20
+ 'getpath($p | split(".")) // empty | if type == "string" then . else tojson end'
21
+ else
22
+ printf '%s' "$HOOK_INPUT" | node -e '
23
+ let s = "";
24
+ process.stdin.on("data", (d) => (s += d)).on("end", () => {
25
+ let v = JSON.parse(s || "{}");
26
+ for (const k of process.argv[1].split(".")) v = v == null ? undefined : v[k];
27
+ if (v == null || v === false) return;
28
+ process.stdout.write(typeof v === "string" ? v : JSON.stringify(v));
29
+ });' "$1"
30
+ fi
31
+ }
32
+
33
+ # hook_context <Event> <texte> : contexte additionnel visible par le modèle.
34
+ hook_context() {
35
+ if hook_has_jq; then
36
+ jq -cn --arg e "$1" --arg c "$2" '{hookSpecificOutput: {hookEventName: $e, additionalContext: $c}}'
37
+ else
38
+ node -e 'process.stdout.write(JSON.stringify({hookSpecificOutput: {hookEventName: process.argv[1], additionalContext: process.argv[2]}}) + "\n")' "$1" "$2"
39
+ fi
40
+ }
41
+
42
+ hook_block() {
43
+ printf 'BLOCKED: %s\n' "$1" >&2
44
+ exit 2
45
+ }
46
+
47
+ # Garde de sécurité sans parseur JSON : on bloque plutôt que de tout laisser passer.
48
+ hook_require_parser() {
49
+ hook_has_parser || hook_block "hook requires jq or node to inspect the tool input"
50
+ }
51
+
52
+ # stdin -> stdout sans le corps des heredocs (`<<EOF`, `<<-'EOF'`) : ce sont des
53
+ # données (message de commit, fichier écrit), pas des commandes à analyser.
54
+ # Les here-strings `<<<` ne sont pas concernées.
55
+ hook_strip_heredocs() {
56
+ awk '
57
+ skip { t = $0; sub(/^[\t]+/, "", t); if (t == delim) skip = 0; next }
58
+ {
59
+ print
60
+ rest = $0
61
+ while (match(rest, /<<-?[ \t]*["\047]?[A-Za-z_][A-Za-z0-9_]*/)) {
62
+ pre = substr(rest, RSTART - 1, 1); tok = substr(rest, RSTART, RLENGTH)
63
+ rest = substr(rest, RSTART + RLENGTH)
64
+ if (RSTART > 1 && pre == "<") continue
65
+ if (substr(rest, 1, 1) == "<") continue
66
+ sub(/^<<-?[ \t]*["\047]?/, "", tok); delim = tok; skip = 1
67
+ }
68
+ }'
69
+ }
70
+
71
+ # Chemin sensible (secrets) ? Basename en minuscules + quelques dossiers connus.
72
+ # Les variantes d'exemple (.example, .sample, .template, .dist, .pub) sont sûres.
73
+ is_sensitive_path() {
74
+ local p b
75
+ p=$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')
76
+ b=${p##*/}
77
+ case "$b" in
78
+ *.example | *.sample | *.template | *.dist | *.defaults | *.pub) return 1 ;;
79
+ esac
80
+ case "$b" in
81
+ .env | .env.* | .envrc | .npmrc | .netrc | .pgpass | .htpasswd | kubeconfig) return 0 ;;
82
+ id_rsa | id_dsa | id_ecdsa | id_ed25519) return 0 ;;
83
+ *.pem | *.key | *.p12 | *.pfx | *.jks | *.keystore) return 0 ;;
84
+ credentials | credentials.json | secrets.yml | secrets.yaml | secrets.json | secrets.toml | secrets.env) return 0 ;;
85
+ esac
86
+ case "$p" in
87
+ */.ssh/* | */.aws/* | */.gnupg/* | */.kube/config | */.docker/config.json) return 0 ;;
88
+ esac
89
+ return 1
90
+ }
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ # PostToolUse(Bash|Grep|Glob) : sortie volumineuse => conseil de synthèse envoyé
3
+ # au modèle via additionalContext (un echo sur stdout ne lui parvient pas).
4
+ set -u
5
+ # shellcheck source=lib/hook-io.sh
6
+ . "$(dirname "${BASH_SOURCE[0]}")/lib/hook-io.sh"
7
+
8
+ hook_has_parser || exit 0
9
+ hook_input
10
+ OUT=$(hook_get tool_response.stdout)
11
+ [ -n "$OUT" ] || OUT=$(hook_get tool_response)
12
+ LEN=${#OUT}
13
+
14
+ if [ "$LEN" -gt 50000 ]; then
15
+ hook_context PostToolUse "Output very large (${LEN} chars). Summarize key findings only; do not repeat output verbatim."
16
+ elif [ "$(hook_get tool_name)" = "Bash" ] && [ "$LEN" -gt 10000 ]; then
17
+ hook_context PostToolUse "Output: $(printf '%s\n' "$OUT" | wc -l | tr -d ' ') lines. Extract only relevant information."
18
+ fi
19
+ exit 0
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+ # PreToolUse(Edit|Write|NotebookEdit) : refuse l'écriture des fichiers de secrets
3
+ # (.env, clés, credentials). Les fichiers d'exemple (.env.example…) restent éditables.
4
+ set -u
5
+ # shellcheck source=lib/hook-io.sh
6
+ . "$(dirname "${BASH_SOURCE[0]}")/lib/hook-io.sh"
7
+
8
+ hook_require_parser
9
+ hook_input
10
+ FILE=$(hook_get tool_input.file_path)
11
+ [ -n "$FILE" ] || FILE=$(hook_get tool_input.notebook_path)
12
+
13
+ if [ -n "$FILE" ] && is_sensitive_path "$FILE"; then
14
+ hook_block "Cannot modify sensitive file: $FILE"
15
+ fi
16
+ exit 0
@@ -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