jorgex-stack 1.0.1 → 1.0.3

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 (99) hide show
  1. package/PRD.md +310 -297
  2. package/README.md +68 -56
  3. package/dist/cli.js +37 -3
  4. package/package.json +1 -1
  5. package/stack/agents/code-simplifier.md +21 -10
  6. package/stack/agents/implementer.md +1 -0
  7. package/stack/agents/orchestrator.md +194 -192
  8. package/stack/agents/security-auditor.md +7 -0
  9. package/stack/agents/silent-failure-hunter.md +7 -0
  10. package/stack/agents/test-analyzer.md +7 -0
  11. package/stack/agents/tester.md +71 -71
  12. package/stack/agents/type-design-analyzer.md +1 -1
  13. package/stack/commands/lean-audit.md +59 -0
  14. package/stack/commands/xreview.md +82 -80
  15. package/stack/hooks/hooks.json +18 -18
  16. package/stack/scripts/post-pr-review.cjs +159 -156
  17. package/stack/skills/diagnose/SKILL.md +117 -117
  18. package/stack/skills/diagnose/scripts/hitl-loop.template.sh +41 -41
  19. package/stack/skills/find-skills/SKILL.md +133 -133
  20. package/stack/skills/lean-code/SKILL.md +69 -0
  21. package/stack/skills/mcp-builder/LICENSE.txt +201 -201
  22. package/stack/skills/mcp-builder/SKILL.md +236 -236
  23. package/stack/skills/mcp-builder/reference/evaluation.md +601 -601
  24. package/stack/skills/mcp-builder/reference/mcp_best_practices.md +249 -249
  25. package/stack/skills/mcp-builder/reference/node_mcp_server.md +969 -969
  26. package/stack/skills/mcp-builder/reference/python_mcp_server.md +718 -718
  27. package/stack/skills/mcp-builder/scripts/connections.py +151 -151
  28. package/stack/skills/mcp-builder/scripts/evaluation.py +373 -373
  29. package/stack/skills/mcp-builder/scripts/example_evaluation.xml +22 -22
  30. package/stack/skills/mcp-builder/scripts/requirements.txt +2 -2
  31. package/stack/skills/obsidian-cli/SKILL.md +106 -106
  32. package/stack/skills/obsidian-markdown/SKILL.md +196 -196
  33. package/stack/skills/obsidian-markdown/references/CALLOUTS.md +58 -58
  34. package/stack/skills/obsidian-markdown/references/EMBEDS.md +63 -63
  35. package/stack/skills/obsidian-markdown/references/PROPERTIES.md +61 -61
  36. package/stack/skills/react-doctor/SKILL.md +19 -19
  37. package/stack/skills/skill-creator/LICENSE.txt +201 -201
  38. package/stack/skills/skill-creator/agents/analyzer.md +274 -274
  39. package/stack/skills/skill-creator/agents/comparator.md +202 -202
  40. package/stack/skills/skill-creator/agents/grader.md +223 -223
  41. package/stack/skills/skill-creator/assets/eval_review.html +146 -146
  42. package/stack/skills/skill-creator/eval-viewer/generate_review.py +471 -471
  43. package/stack/skills/skill-creator/eval-viewer/viewer.html +1325 -1325
  44. package/stack/skills/skill-creator/references/schemas.md +430 -430
  45. package/stack/skills/skill-creator/scripts/aggregate_benchmark.py +401 -401
  46. package/stack/skills/skill-creator/scripts/generate_report.py +326 -326
  47. package/stack/skills/skill-creator/scripts/improve_description.py +248 -248
  48. package/stack/skills/skill-creator/scripts/package_skill.py +136 -136
  49. package/stack/skills/skill-creator/scripts/quick_validate.py +102 -102
  50. package/stack/skills/skill-creator/scripts/run_eval.py +310 -310
  51. package/stack/skills/skill-creator/scripts/run_loop.py +332 -332
  52. package/stack/skills/skill-creator/scripts/utils.py +47 -47
  53. package/stack/skills/supabase/SKILL.md +135 -135
  54. package/stack/skills/supabase/assets/feedback-issue-template.md +17 -17
  55. package/stack/skills/supabase/references/skill-feedback.md +17 -17
  56. package/stack/skills/supabase-postgres-best-practices/SKILL.md +64 -64
  57. package/stack/skills/supabase-postgres-best-practices/references/_contributing.md +170 -170
  58. package/stack/skills/supabase-postgres-best-practices/references/_sections.md +39 -39
  59. package/stack/skills/supabase-postgres-best-practices/references/_template.md +34 -34
  60. package/stack/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -55
  61. package/stack/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -49
  62. package/stack/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -46
  63. package/stack/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -44
  64. package/stack/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -41
  65. package/stack/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -46
  66. package/stack/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -54
  67. package/stack/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -53
  68. package/stack/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -50
  69. package/stack/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -50
  70. package/stack/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -56
  71. package/stack/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -68
  72. package/stack/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -50
  73. package/stack/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -54
  74. package/stack/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -45
  75. package/stack/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -55
  76. package/stack/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -55
  77. package/stack/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -44
  78. package/stack/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -40
  79. package/stack/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -48
  80. package/stack/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -43
  81. package/stack/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -45
  82. package/stack/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -80
  83. package/stack/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -46
  84. package/stack/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -59
  85. package/stack/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -55
  86. package/stack/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -55
  87. package/stack/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -61
  88. package/stack/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -54
  89. package/stack/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -50
  90. package/stack/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -63
  91. package/stack/skills/tdd/SKILL.md +109 -109
  92. package/stack/skills/tdd/deep-modules.md +33 -33
  93. package/stack/skills/tdd/interface-design.md +31 -31
  94. package/stack/skills/tdd/mocking.md +59 -59
  95. package/stack/skills/tdd/refactoring.md +10 -10
  96. package/stack/skills/tdd/tests.md +61 -61
  97. package/stack/skills/to-issues/SKILL.md +83 -83
  98. package/stack/skills/to-prd/SKILL.md +72 -72
  99. package/upstreams.json +96 -96
package/README.md CHANGED
@@ -1,56 +1,68 @@
1
- # JorgeX Stack
2
-
3
- Harness multi-agente portable: una sola fuente de configuración — 15 agentes, 18 skills, hooks, memoria persistente ([Engram](https://github.com/Gentleman-Programming/engram)), MCPs y system prompt — instalable con un comando en **Claude Code**, **Codex CLI** y **OpenCode**.
4
-
5
- > Inspirado en [gentle-ai](https://github.com/Gentleman-Programming/gentle-ai), reconstruido para el stack JorgeX.
6
-
7
- ## Uso
8
-
9
- Instalación y uso vía npm (no requiere clonar el repo):
10
-
11
- ```
12
- pnpm dlx jorgex-stack install # interactivo: elige runtimes y confirma
13
- pnpm dlx jorgex-stack models # picker de modelos por runtime y tier (strong/standard/cheap)
14
- pnpm dlx jorgex-stack sync # re-aplica la config (idempotente; limpia huérfanos)
15
- pnpm dlx jorgex-stack doctor # verifica que todo está sano (Engram, drift, hooks, keys)
16
- pnpm dlx jorgex-stack update # interactivo: scan stack/Engram/skills, multiselect, diff/confirm
17
- # Con --check: solo informe sin cambios
18
- # Con --yes: modo batch (solo informe)
19
- pnpm dlx jorgex-stack restore # restaura un backup
20
- pnpm dlx jorgex-stack uninstall # desinstala lo nuestro y conserva lo del usuario (Engram intacto)
21
- ```
22
-
23
- En desarrollo (desde un clon), los mismos comandos van por `pnpm cli <comando>` (ver [Desarrollo](#desarrollo)).
24
-
25
- Todo comando soporta `--dry-run`, `--yes` y `--target-dir <dir>` (pruebas sin tocar la config real). Las escrituras llevan backup automático y verificación de idempotencia; el merge en configs de usuario es quirúrgico (secciones marcadas en markdown, upsert en JSON/TOML) — lo tuyo no se toca jamás.
26
-
27
- ### Update: flujo interactivo
28
-
29
- `update` gestiona tres fuentes:
30
-
31
- 1. **Stack** (jorgex-stack): detecta si es clon git o instalación global, oferece actualización con confirmación.
32
- 2. **Engram** (binario): detecta la versión instalada, ofrece actualización con **canal nativo** (brew → `go install` → URL releases). No hace falta parar nada: igual que el upstream en macOS/Linux, los procesos vivos siguen con la versión antigua hasta reiniciar los clientes; en Windows el `.exe` en uso se rota por rename antes de instalar. **Backup automático de la DB antes de actualizar**. La base de datos y las memorias jamás se tocan.
33
- 3. **Skills vendorizadas**: detecta cambios en los upstream registrados en `upstreams.json`, descarga el upstream a temporal, **muestra diff obligatorio** y solicita confirmación. Las skills con cambios locales (`modified: true`) alertan y exigen doble confirmación.
34
-
35
- Uso:
36
- - `update --check`: scan de versiones sin aplicar cambios.
37
- - `update` (TTY, sin `--yes`): multiselect interactivo con diffs visibles y confirmaciones paso a paso.
38
- - `update --yes` o sin TTY: se comporta como `--check` (solo informe).
39
-
40
- Autenticación con GitHub: las consultas usan `GH_TOKEN`/`GITHUB_TOKEN` del entorno o, si no existen, el token de tu sesión de `gh` CLI (`gh auth token` — solo lectura local, nunca se loguea ni persiste). Sin token, GitHub limita las consultas en paralelo y algunos upstreams pueden salir como "sin conexión".
41
-
42
- ## Estado
43
-
44
- **v1.0.0 — publicada en [npm](https://www.npmjs.com/package/jorgex-stack).** CLI completo y migración real ejecutada (F6); el stack es la única fuente de configuración. El diseño, las decisiones (D1–D9) y el roadmap están en [PRD.md](PRD.md).
45
-
46
- ## Desarrollo
47
-
48
- Requisitos: Node 20 y pnpm (nunca npm).
49
-
50
- ```
51
- pnpm install
52
- pnpm build # tsup dist/
53
- pnpm typecheck
54
- pnpm test # vitest
55
- pnpm cli --help
56
- ```
1
+ # JorgeX Stack
2
+
3
+ Harness multi-agente portable: una sola fuente de configuración — 15 agentes, 18 skills, hooks, memoria persistente ([Engram](https://github.com/Gentleman-Programming/engram)), MCPs y system prompt — instalable con un comando en **Claude Code**, **Codex CLI** y **OpenCode**.
4
+
5
+ > Inspirado en [gentle-ai](https://github.com/Gentleman-Programming/gentle-ai), reconstruido para el stack JorgeX.
6
+
7
+ ## Uso
8
+
9
+ Instalación y uso vía npm (no requiere clonar el repo):
10
+
11
+ ```
12
+ pnpm dlx jorgex-stack install # interactivo: elige runtimes y confirma
13
+ pnpm dlx jorgex-stack models # picker de modelos por runtime y tier (strong/standard/cheap)
14
+ pnpm dlx jorgex-stack sync # re-aplica la config (idempotente; limpia huérfanos)
15
+ pnpm dlx jorgex-stack doctor # verifica que todo está sano (Engram, drift, hooks, keys)
16
+ pnpm dlx jorgex-stack update # interactivo: scan stack/Engram/skills, multiselect, diff/confirm
17
+ # Con --check: solo informe sin cambios
18
+ # Con --yes: modo batch (solo informe)
19
+ pnpm dlx jorgex-stack restore # restaura un backup
20
+ pnpm dlx jorgex-stack uninstall # desinstala lo nuestro y conserva lo del usuario (Engram intacto)
21
+ ```
22
+
23
+ En desarrollo (desde un clon), los mismos comandos van por `pnpm cli <comando>` (ver [Desarrollo](#desarrollo)).
24
+
25
+ Todo comando soporta `--dry-run`, `--yes` y `--target-dir <dir>` (pruebas sin tocar la config real). Las escrituras llevan backup automático y verificación de idempotencia; el merge en configs de usuario es quirúrgico (secciones marcadas en markdown, upsert en JSON/TOML) — lo tuyo no se toca jamás.
26
+
27
+ ### Update: flujo interactivo
28
+
29
+ `update` gestiona tres fuentes:
30
+
31
+ 1. **Stack** (jorgex-stack): detecta si es clon git o instalación global, oferece actualización con confirmación.
32
+ 2. **Engram** (binario): detecta la versión instalada, ofrece actualización con **canal nativo** (brew → `go install` → URL releases). No hace falta parar nada: igual que el upstream en macOS/Linux, los procesos vivos siguen con la versión antigua hasta reiniciar los clientes; en Windows el `.exe` en uso se rota por rename antes de instalar. **Backup automático de la DB antes de actualizar**. La base de datos y las memorias jamás se tocan.
33
+ 3. **Skills vendorizadas**: detecta cambios en los upstream registrados en `upstreams.json`, descarga el upstream a temporal, **muestra diff obligatorio** y solicita confirmación. Las skills con cambios locales (`modified: true`) alertan y exigen doble confirmación.
34
+
35
+ Uso:
36
+ - `update --check`: scan de versiones sin aplicar cambios.
37
+ - `update` (TTY, sin `--yes`): multiselect interactivo con diffs visibles y confirmaciones paso a paso.
38
+ - `update --yes` o sin TTY: se comporta como `--check` (solo informe).
39
+
40
+ Autenticación con GitHub: las consultas usan `GH_TOKEN`/`GITHUB_TOKEN` del entorno o, si no existen, el token de tu sesión de `gh` CLI (`gh auth token` — solo lectura local, nunca se loguea ni persiste). Sin token, GitHub limita las consultas en paralelo y algunos upstreams pueden salir como "sin conexión".
41
+
42
+ ## Estado
43
+
44
+ CLI completo y migración real ejecutada (F6); el stack es la única fuente de configuración. Las versiones se publican automáticamente en [npm](https://www.npmjs.com/package/jorgex-stack) según el flujo descrito en [Publicación](#publicación). El diseño, las decisiones (D1–D9) y el roadmap están en [PRD.md](PRD.md).
45
+
46
+ ## Publicación
47
+
48
+ La release la dispara el push/merge a `main` y GitHub Actions; también hay `workflow_dispatch` de recuperación sobre `main` con `release_sha` opcional. `validate` resuelve una sola vez la SHA objetivo y la expone como `target_sha`; `bump` reutiliza esa SHA. Si no pasas `release_sha`, `validate` fija `target_sha` a `origin/main` tras `fetch`; si la pasas, debe ser una SHA completa de 40 hex perteneciente a `main` o falla en rojo con instrucción de recuperación. El modo sin `release_sha` solo es válido para publicar `origin/main` cuando la versión aún no existe en npm; si la versión ya existe y falta el tag, el workflow falla y exige `workflow_dispatch` con `release_sha=<sha publicada>`. No se usa `pnpm publish` ni hace falta login de npm:
49
+
50
+ - **Patch automático**: si el push a `main` contiene cambios publicables y la versión actual de `package.json` ya está en npm, el workflow busca el primer patch libre (`x+1`, `x+2`, …), commitea `chore(release): bump version to v…` y publica. Si ya existe el tag `v<package.version>`, usa ese punto como base acumulada; si no, cae a `github.event.before`. Las runs obsoletas se abortan tras `git fetch origin main --tags` si `origin/main` ya no coincide con `GITHUB_SHA`.
51
+ - **Recuperación manual**: una ejecución manual sobre `main` con `release_sha` publica esa SHA si todavía no existe en npm, sin volver a bumpear; si la versión ya está en npm pero falta el tag `v<version>`, el workflow falla y te obliga a relanzar con `release_sha=<sha publicada>` para no tagear `origin/main`. `release_sha` debe ser una SHA completa de 40 hex y pertenecer a `main`; refs mutables (`main`, tags, `main~1`) se rechazan. Si no pasas `release_sha`, `validate` resuelve `origin/main` una vez, lo expone como `target_sha` y `bump` usa esa SHA validada.
52
+ - **Sin release**: cambios solo en `work/`, `worktrees/`, tests o archivos no listados como publicables (`src/`, `stack/`, `upstreams.json`, `package.json`, `pnpm-lock.yaml`, `tsconfig.json`, `tsup.config.ts`, `README.md`, `PRD.md`) no generan release.
53
+ - **Minor y major manuales**: bump explícito de `package.json` en el PR (el workflow detecta que el siguiente patch ya existe en npm y exige el bump).
54
+ - **OIDC / trusted publishing**: el job de publicación usa `id-token: write` y `registry-url` de `setup-node`; el job de bump/push solo tiene `contents: write`; el `tag-release` solo escribe `contents` y no usa OIDC. No hay `NPM_TOKEN` ni `NODE_AUTH_TOKEN` en ningún secreto. El `tag-release` solo corre si `publish` fue `success` o `skipped` con `tag_needed=true` y conserva su validación SHA como última defensa. La única excepción a la regla "pnpm siempre" son `npm pack --dry-run --ignore-scripts` y `npm publish --ignore-scripts --provenance` en el paso final, por compatibilidad y hardening del registry.
55
+
56
+ Los detalles de diseño están en [PRD §7.6](PRD.md#76-publicación-automática-en-npm).
57
+
58
+ ## Desarrollo
59
+
60
+ Requisitos: Node ≥ 20 y pnpm (nunca npm).
61
+
62
+ ```
63
+ pnpm install
64
+ pnpm build # tsup → dist/
65
+ pnpm typecheck
66
+ pnpm test # vitest
67
+ pnpm cli --help
68
+ ```
package/dist/cli.js CHANGED
@@ -1098,8 +1098,13 @@ function createBackup(files, label, root = backupsRoot()) {
1098
1098
  const checksum = compositeChecksum(existing);
1099
1099
  const latest = listBackups(root)[0];
1100
1100
  if (latest?.checksum === checksum) return latest;
1101
- const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${label}`;
1102
- const dir = path10.join(root, id);
1101
+ const base = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${label}`;
1102
+ let id = base;
1103
+ let dir = path10.join(root, id);
1104
+ for (let n = 1; fs6.existsSync(dir); n++) {
1105
+ id = `${base}-${n}`;
1106
+ dir = path10.join(root, id);
1107
+ }
1103
1108
  ensureDir(path10.join(dir, "files"));
1104
1109
  const entries = existing.map((original, i) => {
1105
1110
  const stored = path10.join(dir, "files", `${String(i).padStart(4, "0")}-${path10.basename(original)}`);
@@ -2703,8 +2708,37 @@ function cancelled() {
2703
2708
  return 1;
2704
2709
  }
2705
2710
 
2711
+ // src/lib/release.ts
2712
+ import fs17 from "fs";
2713
+ import path24 from "path";
2714
+ import { execFileSync as execFileSync5 } from "child_process";
2715
+ import { fileURLToPath as fileURLToPath2 } from "url";
2716
+ function findPackageJson() {
2717
+ let dir = path24.dirname(fileURLToPath2(import.meta.url));
2718
+ for (let i = 0; i < 6; i++) {
2719
+ const candidate = path24.join(dir, "package.json");
2720
+ if (fs17.existsSync(candidate)) return candidate;
2721
+ dir = path24.dirname(dir);
2722
+ }
2723
+ throw new Error("No se encontr\xF3 package.json cerca del CLI.");
2724
+ }
2725
+ function readPackageVersion() {
2726
+ return readPackageMetadata().version;
2727
+ }
2728
+ function readPackageMetadata() {
2729
+ const packageJson = findPackageJson();
2730
+ const raw = fs17.readFileSync(packageJson, "utf8");
2731
+ const parsed = JSON.parse(raw);
2732
+ const name = typeof parsed.name === "string" ? parsed.name.trim() : "";
2733
+ const version = typeof parsed.version === "string" ? parsed.version.trim() : "";
2734
+ if (name === "" || version === "") {
2735
+ throw new Error("package.json no expone nombre o versi\xF3n v\xE1lidos.");
2736
+ }
2737
+ return { name, version };
2738
+ }
2739
+
2706
2740
  // src/cli.ts
2707
- var VERSION = "0.6.0";
2741
+ var VERSION = readPackageVersion();
2708
2742
  var COMMANDS = ["install", "sync", "models", "update", "doctor", "restore", "uninstall"];
2709
2743
  function parseFlags(args) {
2710
2744
  const flags = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jorgex-stack",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Harness multi-agente portable: instala la config JorgeX (agentes, skills, hooks, Engram, MCPs) en Claude Code, Codex CLI y OpenCode",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -9,14 +9,15 @@ bash: git-read
9
9
 
10
10
  # Code Simplifier
11
11
 
12
- You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions.
12
+ You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Use the `lean-code` skill as your anti-bloat lens and source of truth for when code should disappear, shrink, or reuse existing helpers. You prioritize readable, explicit code over overly compact solutions.
13
13
 
14
14
  You are read-only: you analyze recently modified code and **propose** refinements as concrete suggestions (with file path, line and a before/after snippet). You never write or edit files yourself.
15
15
 
16
16
  **First actions, in order**:
17
17
 
18
- 1. **Get the diff.** When you're given BASE and HEAD branches, review only `git diff <BASE>...HEAD` using exactly those branches — never assume `main`. If no branches are given, review the working diff (`git diff`).
19
- 2. Load the `agent-delegation` skill.
18
+ 1. **Resolve scope.** If you're given an audit scope (repo/path root), audit only that path and do not fall back to `git diff`. Otherwise, when you're given BASE and HEAD branches, review only `git diff <BASE>...HEAD` using exactly those branches — never assume `main`. If no audit scope or branches are given, review the working diff (`git diff`).
19
+ 2. Load the `lean-code` skill.
20
+ 3. Load the `agent-delegation` skill.
20
21
 
21
22
  **Final output, last of all**: your final report (ending with the Result contract) must be the very last thing you emit. If you need to save anything to memory, do it BEFORE that output — never after.
22
23
 
@@ -24,6 +25,13 @@ You are read-only: you analyze recently modified code and **propose** refinement
24
25
 
25
26
  Your lane: behavior-preserving clarity and structure of the CODE itself — nothing else. Bugs, guideline violations and comment quality belong to other specialists (the `agent-delegation` skill has the map): don't report them — note them as delegations in your Result contract. Don't propose adding, rewriting or deleting comments.
26
27
 
28
+ ## 4R Readability Lens
29
+
30
+ - Propose simplifications only when they clearly reduce cognitive load: magic numbers with business meaning, long parameter lists, duplicated logic, dead code, naming drift, or deep nesting.
31
+ - Back proposals with evidence from the code shape, not taste; avoid subjective style nits.
32
+ - Keep the scope strictly readability/maintainability: do not turn bug fixes, security concerns, test gaps, or error-handling problems into simplification suggestions.
33
+ - Prefer small, local clarifications over structural rewrites that change how the code is organized without a clear readability win.
34
+
27
35
  Your proposed refinements must:
28
36
 
29
37
  1. **Preserve Functionality**: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
@@ -46,20 +54,23 @@ Your proposed refinements must:
46
54
  - Prioritize "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
47
55
  - Make the code harder to debug or extend
48
56
 
49
- 5. **Focus Scope**: Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.
57
+ 5. **Focus Scope**: Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader audit scope.
50
58
 
51
59
  Your process:
52
60
 
53
61
  1. Identify the recently modified code sections
54
- 2. Analyze for opportunities to improve elegance and consistency
55
- 3. Check proposals against project-specific best practices and coding standards
56
- 4. Ensure proposed changes keep all functionality unchanged
57
- 5. Verify the proposed code is simpler and more maintainable
58
- 6. Report only significant changes that affect understanding
62
+ 2. Run a lean deletion pass first: what can disappear, become stdlib/native/platform code, reuse existing project code, or lose a premature abstraction?
63
+ 3. Analyze remaining opportunities to improve elegance and consistency
64
+ 4. Check proposals against project-specific best practices and coding standards
65
+ 5. Ensure proposed changes keep all functionality unchanged
66
+ 6. Verify the proposed code is simpler and more maintainable
67
+ 7. Report only significant changes that affect understanding
59
68
 
60
69
  ## Output format
61
70
 
62
- For each suggestion provide: file path and line, what to simplify and why, and a before/after snippet. If nothing meaningful can be simplified, say so briefly. Your goal is to surface refinements that meet the highest standards of elegance and maintainability while preserving complete functionality — the implementer applies them.
71
+ For each suggestion provide: file path and line, what to simplify and why, and a before/after snippet when useful. Prefix each lean finding with the matching `lean-code` tag (for example `shrink:` or `delete:`).
72
+
73
+ End lean-heavy reports with `net: -<N> lines possible` when you can estimate it. If nothing meaningful can be simplified, say so briefly. Your goal is to surface refinements that meet the highest standards of elegance and maintainability while preserving complete functionality — the implementer applies them.
63
74
 
64
75
  ## Types of refinement to propose
65
76
 
@@ -23,6 +23,7 @@ You usually receive a clear design (often from an analyst), and the project's st
23
23
 
24
24
  1. **Confirm the libraries you'll actually use** when you're unsure of the exact one or its API: check `package.json` (or the equivalent manifest) and the touched files — e.g. state (Zustand, Redux), data-fetching (TanStack Query, SWR), forms, styling, ORM. Use each library's real API and patterns; don't hand-roll what a present library already does.
25
25
  2. **Mirror existing conventions**: look at the files you'll touch and their neighbors, and follow their style, patterns and imports. Don't introduce a new pattern without need.
26
+ 3. **Load `lean-code` before non-trivial code**: use it as the ladder before you add a helper, wrapper, abstraction, or dependency. Ask whether the code is needed at all, whether stdlib/native/project helpers already solve it, and whether a smaller change works.
26
27
 
27
28
  ## Contract
28
29