lean-agent-harness 0.0.0-stage → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/install.sh ADDED
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env bash
2
+ # Lean Agent Harness — cross-platform installer (curl | bash)
3
+ # Modes: local (project) | global (user home). Detection + flags, never hangs without a TTY.
4
+ set -euo pipefail
5
+
6
+ REPO="${GITHUB_REPO:-lnardev/lean-agent-harness}"
7
+ BRANCH="${GITHUB_BRANCH:-main}"
8
+ # LAH_VERSION pins a release tag (X.Y.Z) instead of the branch; LAH_SHA256 verifies the downloaded archive;
9
+ # LAH_ARCHIVE_URL overrides the download URL entirely (mirrors, tests).
10
+
11
+ GREEN='\033[32m'; CYAN='\033[36m'; YELLOW='\033[33m'; BOLD='\033[1m'; DIM='\033[2m'; NC='\033[0m'
12
+
13
+ TARGET_MODE=""
14
+ STRATEGY=""
15
+ PROFILE="full"
16
+ while [ $# -gt 0 ]; do
17
+ case "$1" in
18
+ --global|-g) TARGET_MODE="global" ;;
19
+ --local|-l) TARGET_MODE="local" ;;
20
+ --all) STRATEGY="all" ;;
21
+ --auto) STRATEGY="auto" ;;
22
+ --profile)
23
+ PROFILE="${2:-}"
24
+ case "$PROFILE" in
25
+ core|full) shift ;;
26
+ *) echo "Perfil desconocido: \"$PROFILE\". Usa: core | full" >&2; exit 64 ;;
27
+ esac
28
+ ;;
29
+ *) echo "Flag desconocido: $1 (solo: --global, --local, --all, --auto, --profile core|full)" >&2; exit 64 ;;
30
+ esac
31
+ shift
32
+ done
33
+
34
+ TTY_DEV=""
35
+ if [ -c /dev/tty ]; then TTY_DEV="/dev/tty"; fi
36
+
37
+ ask() {
38
+ local response=""
39
+ if [ -n "$TTY_DEV" ]; then
40
+ printf "%b" "$1" > "/dev/tty"
41
+ read -r response < "/dev/tty" || true
42
+ fi
43
+ printf "%s" "${response:-$2}"
44
+ }
45
+
46
+ echo -e "\n${BOLD}${CYAN}Lean Agent Harness${NC} — Instalador Universal\n"
47
+
48
+ # 1. Mode: global vs local
49
+ if [ -z "$TARGET_MODE" ]; then
50
+ if [ -n "$TTY_DEV" ]; then
51
+ echo -e "${BOLD}¿Dónde deseas instalar el arnés?${NC}"
52
+ echo -e " ${CYAN}[1]${NC} Global (~/ en carpetas de usuario)"
53
+ echo -e " ${CYAN}[2]${NC} Local (en el proyecto actual: $(pwd))"
54
+ mode_choice="$(ask "Selecciona [1/2] (por defecto 1): " "1")"
55
+ [ "$mode_choice" = "2" ] && TARGET_MODE="local" || TARGET_MODE="global"
56
+ echo ""
57
+ else
58
+ TARGET_MODE="global"
59
+ fi
60
+ fi
61
+
62
+ if [ "$TARGET_MODE" = "global" ]; then
63
+ BASE_DIR="${HOME}"
64
+ echo -e "Modo: ${BOLD}Global${NC} (${DIM}${BASE_DIR}${NC})\n"
65
+ else
66
+ BASE_DIR="$PWD"
67
+ echo -e "Modo: ${BOLD}Local${NC} (${DIM}${BASE_DIR}${NC})\n"
68
+ fi
69
+
70
+ # 2. Source: local override for testing, otherwise the GitHub tarball
71
+ if [ -n "${LAH_SOURCE:-}" ] && [ -d "$LAH_SOURCE" ]; then
72
+ SRC="$LAH_SOURCE"
73
+ echo -e "${DIM}Fuente: $SRC (override local)${NC}"
74
+ else
75
+ SRC="$(mktemp -d)"
76
+ ARCHIVE="$(mktemp)"
77
+ trap 'rm -rf "$SRC" "$ARCHIVE"' EXIT
78
+
79
+ if [ -n "${LAH_VERSION:-}" ]; then
80
+ if ! [[ "$LAH_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
81
+ echo "LAH_VERSION inválida: \"$LAH_VERSION\" (usa X.Y.Z)" >&2
82
+ exit 64
83
+ fi
84
+ ARCHIVE_URL="https://github.com/${REPO}/archive/refs/tags/v${LAH_VERSION}.tar.gz"
85
+ else
86
+ ARCHIVE_URL="https://github.com/${REPO}/archive/refs/heads/${BRANCH}.tar.gz"
87
+ fi
88
+ ARCHIVE_URL="${LAH_ARCHIVE_URL:-$ARCHIVE_URL}"
89
+
90
+ echo -e "${DIM}Descargando arnés desde ${ARCHIVE_URL}...${NC}"
91
+ curl -fsSL "$ARCHIVE_URL" -o "$ARCHIVE"
92
+
93
+ if [ -n "${LAH_SHA256:-}" ]; then
94
+ if command -v sha256sum >/dev/null 2>&1; then actual="$(sha256sum "$ARCHIVE" | cut -d' ' -f1)"
95
+ else actual="$(shasum -a 256 "$ARCHIVE" | cut -d' ' -f1)"; fi
96
+ expected="$(printf '%s' "$LAH_SHA256" | tr 'A-F' 'a-f')"
97
+ if [ "$actual" != "$expected" ]; then
98
+ echo -e "Checksum SHA-256 no coincide: se esperaba ${expected} y se obtuvo ${actual}. No se instaló nada." >&2
99
+ exit 1
100
+ fi
101
+ echo -e "${DIM}Checksum SHA-256 verificado.${NC}"
102
+ else
103
+ echo -e "${YELLOW}LAH_SHA256 no definido: el arnés se instala sin verificar el checksum.${NC}"
104
+ fi
105
+
106
+ tar -xzf "$ARCHIVE" -C "$SRC" --strip-components=1
107
+ fi
108
+
109
+ # 3. Environment detection (ids match the `target` column of manifest.tsv)
110
+ detect() {
111
+ local shared=false
112
+ [ -d "$BASE_DIR/.claude" ] && echo "claude"
113
+ [ -d "$BASE_DIR/.commandcode" ] && echo "commandcode"
114
+ if [ "$TARGET_MODE" = "global" ]; then
115
+ [ -d "$BASE_DIR/.pi" ] && { echo "pi"; shared=true; }
116
+ [ -d "$BASE_DIR/.codex" ] && { echo "codex"; shared=true; }
117
+ [ -d "$BASE_DIR/.copilot" ] && { echo "copilot"; shared=true; }
118
+ [ -d "$BASE_DIR/.config/opencode" ] && { echo "opencode"; shared=true; }
119
+ else
120
+ [ -d "$BASE_DIR/.opencode" ] && { echo "opencode"; shared=true; }
121
+ for d in .pi .codex .github .cursor; do [ -d "$BASE_DIR/$d" ] && shared=true; done
122
+ fi
123
+ [ -d "$BASE_DIR/.agents" ] && shared=true
124
+ [ "$shared" = true ] && echo "agents"
125
+ return 0
126
+ }
127
+ # String-based, not an array: stock macOS ships bash 3.2 (no mapfile).
128
+ DETECTED="$(detect | tr '\n' ' ')"
129
+ DETECTED="${DETECTED% }"
130
+
131
+ # Space-separated target ids to deploy. "core" (root instruction files) is local-only in the manifest.
132
+ if [ "$TARGET_MODE" = "global" ]; then
133
+ ALL_TARGETS="claude agents pi opencode codex copilot commandcode"
134
+ else
135
+ ALL_TARGETS="claude agents opencode commandcode"
136
+ fi
137
+ SELECTED=""
138
+
139
+ # 3.5 Strategy fallback: non-TTY runs without an explicit strategy must not be a silent no-op
140
+ if [ -z "$STRATEGY" ] && [ -z "$TTY_DEV" ]; then
141
+ [ -n "$DETECTED" ] && STRATEGY="auto" || STRATEGY="all"
142
+ fi
143
+
144
+ if [ -z "$STRATEGY" ]; then
145
+ if [ -n "$DETECTED" ]; then
146
+ echo -e "${BOLD}Se detectaron configuraciones para: ${GREEN}$(echo $DETECTED)${NC}\n"
147
+ echo -e " ${CYAN}[1]${NC} Instalar únicamente en los detectados"
148
+ echo -e " ${CYAN}[2]${NC} Seleccionar manualmente uno por uno"
149
+ echo -e " ${CYAN}[3]${NC} Instalar en todos los soportados"
150
+ choice="$(ask "Elige una opción [1/2/3] (por defecto 1): " "1")"
151
+ case "$choice" in
152
+ 1) STRATEGY="auto" ;;
153
+ 2) STRATEGY="manual" ;;
154
+ *) STRATEGY="all" ;;
155
+ esac
156
+ else
157
+ echo -e " ${YELLOW}No se detectaron carpetas de asistentes previas.${NC}\n"
158
+ echo -e " ${CYAN}[1]${NC} Instalar en todos los soportados"
159
+ echo -e " ${CYAN}[2]${NC} Seleccionar manualmente uno por uno"
160
+ choice="$(ask "Elige una opción [1/2] (por defecto 1): " "1")"
161
+ case "$choice" in 2) STRATEGY="manual" ;; *) STRATEGY="all" ;; esac
162
+ fi
163
+ fi
164
+
165
+ case "$STRATEGY" in
166
+ all)
167
+ SELECTED="$ALL_TARGETS"
168
+ echo -e "${DIM}Estrategia: todos los entornos soportados.${NC}\n"
169
+ ;;
170
+ auto)
171
+ SELECTED="$DETECTED"
172
+ [ -n "$SELECTED" ] || SELECTED="claude" # nothing detected: Claude Code is the sensible baseline
173
+ echo -e "${DIM}Estrategia: detectados ($(echo ${DETECTED:-ninguno})).${NC}\n"
174
+ ;;
175
+ manual)
176
+ echo -e "${BOLD}Responde 's' (sí) o 'n' (no) para cada entorno:${NC}"
177
+ for id in $ALL_TARGETS; do
178
+ [[ "$(ask " ¿Instalar en ${id}? [S/n]: " "s")" =~ ^[Ss] ]] && SELECTED="$SELECTED $id"
179
+ done
180
+ echo ""
181
+ ;;
182
+ esac
183
+
184
+ # 4. Deployment helpers (semantics mirror bin/cli.js: manifest.tsv is the SSOT)
185
+ MANIFEST="$SRC/manifest.tsv"
186
+ [ -f "$MANIFEST" ] || { echo "manifest.tsv no encontrado en $SRC" >&2; exit 1; }
187
+
188
+ # First free backup name: "<name>.bak", then "<name>.bak.1", ... Existing backups are never overwritten.
189
+ backup_path() {
190
+ local candidate="$1.bak" n=1
191
+ while [ -e "$candidate" ]; do candidate="$1.bak.$n"; n=$((n+1)); done
192
+ printf '%s' "$candidate"
193
+ }
194
+
195
+ # Instruction file: a divergent existing destination is preserved as .bak (or the next free .bak.N).
196
+ # mode "if-missing": an existing destination is left untouched (seed files).
197
+ write_instruction() {
198
+ local src="$1" dest="$2" mode="${3:-}"
199
+ if [ "$mode" = "if-missing" ] && [ -e "$dest" ]; then return 0; fi
200
+ mkdir -p "$(dirname "$dest")"
201
+ if [ -f "$dest" ] && ! cmp -s "$src" "$dest"; then cp "$dest" "$(backup_path "$dest")"; fi
202
+ cp "$src" "$dest"
203
+ }
204
+
205
+ # Skill folders omitted by --profile core (profile-extras.txt, shared with bin/cli.js).
206
+ EXCLUDED=""
207
+ if [ "$PROFILE" = "core" ] && [ -f "$SRC/profile-extras.txt" ]; then
208
+ EXCLUDED="$(tr -d '\r' < "$SRC/profile-extras.txt" | grep -v '^#' | grep -v '^[[:space:]]*$' | tr '\n' ' ' || true)"
209
+ fi
210
+
211
+ # copy_dir <from> <to> [skip-extras]: copies top-level entries only, so dotfiles (e.g. Finder's .DS_Store) never ship.
212
+ # With skip-extras, top-level entries listed in EXCLUDED are not copied either.
213
+ copy_dir() {
214
+ mkdir -p "$2"
215
+ local entry name
216
+ for entry in "$1"/*; do
217
+ name="$(basename "$entry")"
218
+ if [ "${3:-}" = "skip-extras" ]; then
219
+ case " $EXCLUDED " in *" $name "*) continue ;; esac
220
+ fi
221
+ cp -R "$entry" "$2/"
222
+ done
223
+ }
224
+
225
+ is_selected() {
226
+ [ "$1" = "core" ] && [ "$TARGET_MODE" = "local" ] && return 0
227
+ case " $SELECTED " in *" $1 "*) return 0 ;; *) return 1 ;; esac
228
+ }
229
+
230
+ # 5. Deploy every manifest row of this scope whose target was selected
231
+ TAB="$(printf '\t')"
232
+ DEPLOYED=""
233
+ while IFS="$TAB" read -r scope tgt kind src dest mode; do
234
+ case "$scope" in ""|\#*) continue ;; esac
235
+ [ "$scope" = "$TARGET_MODE" ] || continue
236
+ is_selected "$tgt" || continue
237
+ case "$kind" in
238
+ file) write_instruction "$SRC/$src" "$BASE_DIR/$dest" "${mode:-}" ;;
239
+ dir)
240
+ if [ "$src" = "skills" ]; then copy_dir "$SRC/$src" "$BASE_DIR/$dest" skip-extras
241
+ else copy_dir "$SRC/$src" "$BASE_DIR/$dest"; fi
242
+ ;;
243
+ esac
244
+ case " $DEPLOYED " in *" $tgt "*) ;; *) DEPLOYED="$DEPLOYED $tgt"; echo -e " ${GREEN}✔${NC} $tgt" ;; esac
245
+ done < "$MANIFEST"
246
+
247
+ echo -e "\n${GREEN}${BOLD}Listo.${NC} Despliegue completado con éxito.\n"
package/manifest.tsv ADDED
@@ -0,0 +1,25 @@
1
+ # Deployment manifest (SSOT for bin/cli.js and install.sh).
2
+ # Columns (tab-separated): scope target kind src dest [mode]
3
+ # scope: local (dest relative to project root) | global (dest relative to $HOME)
4
+ # kind: file (instruction file; a divergent existing dest is saved as .bak) | dir (mirror directory)
5
+ # mode: if-missing (file kind only: never overwrite an existing dest)
6
+ # Target "agents" = the cross-tool Agent Skills location (.agents/skills), read natively by
7
+ # Pi, OpenCode, Codex, Copilot and Cursor. Claude Code reads .claude/skills instead.
8
+ local core file AGENTS.md AGENTS.md
9
+ local core file CLAUDE.md CLAUDE.md
10
+ local core file templates/GLOSSARY.md GLOSSARY.md if-missing
11
+ local claude dir skills .claude/skills
12
+ local agents dir skills .agents/skills
13
+ local opencode dir adapters/opencode/commands .opencode/commands
14
+ local commandcode dir skills .commandcode/skills
15
+ global claude file AGENTS.md .claude/AGENTS.md
16
+ global claude file CLAUDE.md .claude/CLAUDE.md
17
+ global claude dir skills .claude/skills
18
+ global agents dir skills .agents/skills
19
+ global pi file AGENTS.md .pi/agent/AGENTS.md
20
+ global opencode file AGENTS.md .config/opencode/AGENTS.md
21
+ global opencode dir adapters/opencode/commands .config/opencode/commands
22
+ global codex file AGENTS.md .codex/AGENTS.md
23
+ global copilot file AGENTS.md .copilot/copilot-instructions.md
24
+ global commandcode file AGENTS.md .commandcode/AGENTS.md
25
+ global commandcode dir skills .commandcode/skills
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "lean-agent-harness",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.2.0",
4
+ "description": "Zero-bloat, token-efficient agent harness for Claude Code, Cursor, OpenCode, Pi, Codex, and CommandCode.",
5
+ "author": "lnardev",
6
+ "bin": {
7
+ "lean-agent-harness": "bin/cli.js",
8
+ "lean": "bin/cli.js",
9
+ "lah": "bin/cli.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/lnardev/lean-agent-harness.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/lnardev/lean-agent-harness/issues"
17
+ },
18
+ "homepage": "https://github.com/lnardev/lean-agent-harness#readme",
19
+ "files": [
20
+ "bin/",
21
+ "install.sh",
22
+ "manifest.tsv",
23
+ "profile-extras.txt",
24
+ "adapters/",
25
+ "skills/",
26
+ "AGENTS.md",
27
+ "CLAUDE.md",
28
+ "templates/",
29
+ "GLOSSARY.md",
30
+ "LICENSE",
31
+ "README.md",
32
+ "CHANGELOG.md"
33
+ ],
34
+ "scripts": {
35
+ "test": "node --test \"test/*.test.js\"",
36
+ "prepack": "npm test"
37
+ },
38
+ "keywords": [
39
+ "agents",
40
+ "ai",
41
+ "claude-code",
42
+ "cursor",
43
+ "opencode",
44
+ "pi",
45
+ "codex",
46
+ "commandcode",
47
+ "developer-tools"
48
+ ],
49
+ "license": "MIT",
50
+ "engines": {
51
+ "node": ">=18.0.0"
52
+ }
53
+ }
@@ -0,0 +1,6 @@
1
+ # Skills omitted by `--profile core` (one folder name per line). `--profile full` (default) installs all.
2
+ # Their descriptions cost standing tokens in every project regardless of stack.
3
+ impeccable
4
+ humanizer
5
+ diagram-design
6
+ db-migration
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: audit-code
3
+ description: Deep static security audit of a path or the whole workspace. Invoke explicitly.
4
+ argument-hint: [path]
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # audit-code
9
+
10
+ Scope: the given path, else the whole workspace. Skip `.git`, `node_modules`, `.env*`, vendored code, binaries.
11
+
12
+ 1. Load the `security-audit` skill.
13
+ 2. Scan: broken authn/authz (IDOR, missing guards), injection (SQL/NoSQL/XSS/command), hardcoded secrets, insecure deserialization, SSRF, unsanitized trust-boundary crossings, dependency CVEs.
14
+ 3. Report a severity matrix (Critical/High/Med/Low) with `file:line`, failure mechanism, blast radius and the surgical fix. Every finding needs a concrete attack path; no theoretical issues.
@@ -0,0 +1,2 @@
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: code-review
3
+ description: Fast, multi-axis technical code review targeting SonarQube quality gates (Bugs, Code Smells), architectural debt, and diff hygiene.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Code Review
8
+
9
+ Evaluate diffs and PRs strictly against four technical axes. Focus on defects that fail SonarQube quality gates and produce technical debt. Propose the exact remedy, not just the critique.
10
+
11
+ ## The Review Axes
12
+
13
+ 1. **Correctness (SonarQube Bugs):**
14
+ - Null pointer dereferences, unhandled nil/null checks, and type-coercion bugs.
15
+ - Resource leaks: unclosed files, DB connections, HTTP request/response bodies.
16
+ - Logic defects: off-by-one errors, infinite loops, inverted conditions, unchecked error returns.
17
+
18
+ 2. **Readability & Bloat (SonarQube Code Smells):**
19
+ - Dead code: unreachable branches, unused variables, orphan imports, commented-out legacy code.
20
+ - Cyclomatic complexity: deep nesting (>3 levels), massive switch statements without default cases.
21
+ - Duplication: identical logic blocks that must be consolidated.
22
+ - Naming: cryptic variable names without domain meaning (`data`, `temp`, `res`).
23
+
24
+ 3. **Architecture & Boundaries:**
25
+ - Layer leaks: transport or DB logic leaking into domain/business layers.
26
+ - Relocated complexity: refactors that merely shuffle lines instead of eliminating branches.
27
+ - Unnecessary abstractions: premature interfaces, boilerplate wrappers with only one implementation.
28
+
29
+ 4. **Safety & Performance:**
30
+ - Unbounded queries, N+1 patterns, unconstrained pagination.
31
+ - Input validation at system borders (complements `security-audit`).
32
+ - Heavy allocations or redundant calculations inside loops or hot paths.
33
+
34
+ ## Findings Format
35
+
36
+ Report only actionable issues ordered by severity:
37
+
38
+ - **Critical:** Blocks merge / SonarQube red gate. Runtime crash, resource leak, or data corruption.
39
+ - **Required:** Must fix. Code smells, complexity spikes, unhandled boundary cases, broken invariants.
40
+ - **Nit / Optional:** Style suggestions, minor syntactic sugar. Non-blocking.
41
+
42
+ For every reported issue, prescribe the exact structural remedy: *extract helper*, *close resource with defer/finally*, *dispatch via map*, or *collapse redundant branch*.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: commit
3
+ description: Verifies quality gates and creates an atomic Conventional Commit. Invoke explicitly.
4
+ argument-hint: [hint]
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # commit
9
+
10
+ 1. **Gates:** run the typecheck/lint/test scripts declared in the active manifest (`package.json`, `go.mod`, `Makefile`, ...). Require 0 errors and 0 new warnings; quote the summary line.
11
+ 2. **Guard:** no secrets (`.env*`, `*.pem`, `*.key`) staged; no debug residue in the diff.
12
+ 3. **Budget:** check `git diff --cached --stat`. Above 400 changed lines, split the unit or report the overage (rule: `orchestrate` § Change budget).
13
+ 4. **Stage** only this task's files with `git add <files>`; never `git add .`.
14
+ 5. **Message:** Conventional Commits (`feat|fix|refactor|test|docs|chore(scope): summary`), folding in the user's hint. No AI attribution lines.
15
+ 6. `git commit -m "<message>"`, then delete `.tasks/current.md`.
@@ -0,0 +1,2 @@
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: db-migration
3
+ description: Safe, zero-downtime schema migrations and index tuning for SQL databases (PostgreSQL, MySQL, SQLite) and their ORMs.
4
+ ---
5
+
6
+ # Database Migration
7
+
8
+ Design safe, deterministic, zero-downtime schema migrations. Prevent table locks, connection pool exhaustion, and data loss.
9
+
10
+ ## Core Rules
11
+
12
+ 1. **Expand & Contract Pattern:**
13
+ - Never rename or drop columns/tables in a single step.
14
+ - **Step 1 (Expand):** Add new nullable column/table.
15
+ - **Step 2 (Dual-write):** Write to old and new columns in application code.
16
+ - **Step 3 (Backfill):** Backfill historical rows in small batches outside peak traffic.
17
+ - **Step 4 (Contract):** Switch reads to new column, drop legacy writes.
18
+ - **Step 5 (Cleanup):** Drop the legacy column in a subsequent release.
19
+
20
+ 2. **Lock Prevention & Safe Schema Changes:**
21
+ - Add new columns as `NULL` or with database-level defaults that do not trigger full table rewrites.
22
+ - Never run unbounded `UPDATE` or `DELETE` statements inside a migration transaction.
23
+ - Always create indexes concurrently or non-blocking:
24
+ - PostgreSQL: `CREATE INDEX CONCURRENTLY` (outside transactional block).
25
+ - MySQL: `ALGORITHM=INPLACE, LOCK=NONE`.
26
+ - Set lock timeouts (`SET lock_timeout = '2s';`) so a migration fails fast instead of queueing behind long transactions and exhausting the pool.
27
+
28
+ 3. **Foreign Keys & Indices:**
29
+ - Explicitly index foreign key columns to eliminate table locks on cascaded operations.
30
+ - Order composite index columns: equality filters first, range/sort filters second.
31
+
32
+ 4. **Reversibility:**
33
+ - Every migration must have a tested, matching rollback step (`down()` / `down.sql`).
34
+ - Reversible migrations must not assume default states that wipe data on rollback.
35
+
36
+ ## Validation Checklist
37
+
38
+ - [ ] Migration applies and rolls back cleanly on an empty database.
39
+ - [ ] No long-lived exclusive table locks on large tables.
40
+ - [ ] Large data updates/backfills are decoupled into batched background jobs or scripts.
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: diagnosing-bugs
3
+ description: Disciplined 6-phase scientific debugging loop for stubborn defects, race conditions, and performance regressions. Prevents random code thrashing.
4
+ ---
5
+
6
+ # Diagnosing Bugs
7
+
8
+ Resolve defects by elimination of uncertainty, not by brute force. Never apply a second fix attempt to the same hypothesis.
9
+
10
+ ## The 6-Phase Scientific Loop
11
+
12
+ ```text
13
+ 1. REPRODUCE (RED) ──► 2. MINIMIZE ──► 3. HYPOTHESIZE ──► 4. INSTRUMENT ──► 5. FIX (GREEN) ──► 6. REGRESSION TEST
14
+ ```
15
+
16
+ 1. **Reproduce (RED):** Build a failing test that triggers the bug deterministically. If it cannot be reproduced at will, you are debugging noise, not a defect. Capture exact steps and expected vs actual output.
17
+ 2. **Minimize:** Strip parameters, data, and setup until the smallest possible trigger remains. A 5-line repro reveals root causes that a 500-line scenario hides.
18
+ 3. **Hypothesize:** State the exact causal mechanism in writing BEFORE touching production code (*"the cache is populated before the tenant context exists because X runs before Y"*). No hypothesis, no edit.
19
+ 4. **Instrument:** Add targeted temporary logging or assertions that would refute the hypothesis. Prefer assertions over prints. Run once, read, remove.
20
+ 5. **Fix (GREEN):** Apply the surgical correction at the root cause, never a symptom patch. The failing test from phase 1 must now pass.
21
+ 6. **Regression Test:** Promote the repro into a permanent named test. Remove all instrumentation. Run the full suite to rule out collateral damage.
22
+
23
+ ## Circuit Breaker Tie-In
24
+
25
+ After 2 consecutive failed fix attempts: STOP, `git checkout -- <files>`, and start over at phase 3 with a *different* causal mechanism. Repeating the same hypothesis louder is not debugging; it is thrashing.
26
+
27
+ ## Anti-Patterns (Forbidden)
28
+
29
+ * Fixing symptoms (validate input *before* the null deref instead of at the source).
30
+ * Shotgun changes: editing 5 files hoping something sticks.
31
+ * "Works now, ship it": skipping phase 6 leaves the armed time bomb in the codebase.
32
+ * Debugging by adding permanent `console.log`/`print` residue that survives into the commit.
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: diagram-design
3
+ description: Generates publication-grade editorial architecture, system flow, data pipeline, and sequence diagrams as standalone HTML files with inline SVG and CSS.
4
+ ---
5
+
6
+ # Editorial Diagram Design
7
+
8
+ Generate clean, publication-grade diagrams as single, self-contained HTML files (inline SVG + CSS). Never use generic dark-cyan glows, default Mermaid layouts, or diagonal connector lines.
9
+
10
+ ## Visual DNA & Color Palette
11
+
12
+ - **Paper (Background):** `#f5f5f5` (flat canvas).
13
+ - **Ink (Text & Dominant Strokes):** `#2d3142`.
14
+ - **Muted (Secondary Text & Standard Lines):** `#4f5d75`.
15
+ - **Borders & Dividers:** `rgba(45, 49, 66, 0.12)`.
16
+ - **Accent (Bottlenecks / Critical Focus):** `#eb6c36` (coral/terracotta; max 1–2 focal nodes per diagram).
17
+ - **External / Loose Boundaries:** Dashed stroke (`stroke-dasharray="4,4"`).
18
+
19
+ ## Typography (Google Fonts)
20
+
21
+ Embed in HTML header:
22
+ `<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">`
23
+
24
+ - **Diagram Title:** `Instrument Serif`, 28px, normal weight.
25
+ - **Node Names:** `Geist` (sans), 12px, weight 600.
26
+ - **Sublabels & Metadata:** `Geist Mono`, 9px (ports, protocols, batch intervals).
27
+ - **Connector Badges / Eyebrows:** `Geist Mono`, 7–8px, uppercase, tracked (`letter-spacing: 0.08em`).
28
+
29
+ ## SVG Geometry & Layout Standards
30
+
31
+ 1. **4px Grid Discipline:** All coordinates (`x`, `y`), dimensions (`width`, `height`), paddings, and gaps must be multiples of 4.
32
+ 2. **Orthogonal Connectors Only:** Never draw diagonal slanted lines between off-axis nodes. Every bend must be a right-angle elbow with rounded corner (`r=8`). Reserve straight `<line>` strictly for nodes sharing identical axes.
33
+ 3. **Masked Connector Badges:** Place protocol/data labels (e.g., `CSV`, `XLSX`, `LOAD`) inside an opaque `<rect>` filled with `#f5f5f5` (`rx=2`). Maintain a 6px–10px visible gap from the line stroke so the label never cuts through the arrow.
34
+ 4. **Zones & Functional Containers:** Group steps into broad columns/areas (e.g., `COLLECTION`, `PROCESSING`, `DISSEMINATION`). Use a 1px border (`rgba(45,49,66,0.12)`), rounded corners (`rx=8`), and an uppercase mono title tab at the top-left.
35
+ 5. **Node Hierarchy:**
36
+ - *Standard:* `#ffffff` fill, 1px `#2d3142` stroke, 6px radius (`rx=6`).
37
+ - *Bottleneck / Pain-point:* `#fbeee8` fill (`rgba(235,108,54,0.08)`), `#eb6c36` stroke.
38
+ - *External:* Transparent or white fill, dashed border (`stroke-dasharray="4,4"`).
39
+ 6. **Horizontal Bottom Legend:** Position a horizontal legend strip below the diagram nodes, separated by a full-width hairline rule.
40
+
41
+ ## Structural SVG Template
42
+
43
+ Load `references/template.md` before writing the SVG (markers, zones, connectors, masked badge, node box).
@@ -0,0 +1,33 @@
1
+ # Structural SVG Template
2
+
3
+ ```xml
4
+ <svg xmlns="[http://www.w3.org/2000/svg](http://www.w3.org/2000/svg)" viewBox="0 0 1200 680" width="100%" height="100%" role="img">
5
+ <defs>
6
+ <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
7
+ <polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/>
8
+ </marker>
9
+ <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
10
+ <polygon points="0 0, 8 3, 0 6" fill="#eb6c36"/>
11
+ </marker>
12
+ </defs>
13
+
14
+ <!-- Canvas Background -->
15
+ <rect width="100%" height="100%" fill="#f5f5f5"/>
16
+
17
+ <!-- Zones (Painted first) -->
18
+ <rect x="40" y="80" width="320" height="500" rx="8" fill="none" stroke="rgba(45,49,66,0.12)" stroke-width="1"/>
19
+ <text x="60" y="100" fill="#4f5d75" font-family="'Geist Mono', monospace" font-size="8" letter-spacing="0.1em">COLLECTION</text>
20
+
21
+ <!-- Connectors (Drawn before nodes to keep stroke under boxes) -->
22
+ <path d="M 280 180 L 380 180 Q 388 180 388 188 L 388 240" fill="none" stroke="#4f5d75" stroke-width="1.2" marker-end="url(#arrow)"/>
23
+
24
+ <!-- Connector Masked Badge -->
25
+ <rect x="320" y="172" width="28" height="16" rx="2" fill="#f5f5f5"/>
26
+ <text x="334" y="183" fill="#4f5d75" font-family="'Geist Mono', monospace" font-size="8" text-anchor="middle">CSV</text>
27
+
28
+ <!-- Node Box Example -->
29
+ <rect x="60" y="140" width="220" height="72" rx="6" fill="#ffffff" stroke="#2d3142" stroke-width="1"/>
30
+ <text x="80" y="170" fill="#2d3142" font-family="'Geist', sans-serif" font-size="12" font-weight="600">Point-of-Sale Exports</text>
31
+ <text x="80" y="190" fill="#4f5d75" font-family="'Geist Mono', monospace" font-size="9">nightly · CSV</text>
32
+ </svg>
33
+ ```
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: humanizer
3
+ description: Rewrites and cleans prose to eliminate AI writing tics, filler, and corporate inflation. Use for READMEs, docs, and changelogs.
4
+ ---
5
+
6
+ # Humanizer
7
+
8
+ Write and edit prose so it reads like a human technical writer: direct, specific, uninflated. Preserve all factual claims; cut all decorative weight.
9
+
10
+ ## Structural Tells (Banned Patterns)
11
+
12
+ 1. **No "Not X, but Y":** Never build artificial contrast (*"Not just a tool, but a revolution"*). State the fact directly.
13
+ 2. **No Staged Run-ups or Closers:** Cut openers (*"Let's dive in"*, *"Here's what you need to know"*, *"Honestly"*) and dramatic one-line closers (*"That is the real win"*, *"Let that sink in"*).
14
+ 3. **No Aphorisms or Pseudo-depth:** Cut abstract analogies (*"X is the currency of Y"*, *"at its core"*, *"fundamentally"*).
15
+ 4. **No Forced Triads:** Do not force groupings of three (*"speed, scale, and simplicity"*) unless logically necessary.
16
+ 5. **No Decorative Formatting:** Never use bold labels on every list item (`- **Feature:** text`), emojis in headers, or excessive em-dashes (—). Use plain sentences, commas, or periods.
17
+
18
+ ## Vocabulary Blacklist
19
+
20
+ Never use AI stock jargon unless quoting or referring to an exact technical term:
21
+ * *Verbs/Adverbs:* delve, foster, bolster, underscore, highlight, meticulously, quietly.
22
+ * *Nouns:* tapestry, landscape (abstract), testament, interplay, intricacies.
23
+ * *Adjectives:* crucial, pivotal, robust (figurative), vibrant, groundbreaking, multifaceted.
24
+ * *Sales fluff:* nestled, boasting, unparalleled, exciting times ahead.
25
+
26
+ ## Output Standard
27
+
28
+ - **Direct Facts:** Replace *"serves as a testament to"* with *"is"*, and *"features a diverse array of"* with *"has"*.
29
+ - **Neutral Tone:** State limits and bugs plainly without chatbot apologies (*"I hope this helps"*), disclaimers (*"as of my knowledge cutoff"*), or defensive hedging.
30
+ - **Rhythm:** Alternate sentence lengths naturally.
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: impeccable
3
+ description: High-craft frontend UI/UX design, layout, spacing, typography, and visual polish across web and mobile interfaces.
4
+ ---
5
+
6
+ # Impeccable UI Craft
7
+
8
+ Produce production-ready, distinct, and high-fidelity interfaces. Avoid generic placeholder designs, timid component library defaults, and visual clutter.
9
+
10
+ ## Craft Principles
11
+
12
+ 1. **Visual Hierarchy & Typography:**
13
+ - Intentional typographic scale: distinct contrast between display, headers, and body text.
14
+ - Generous line-height for readability (`1.5` - `1.6` on body), tight tracking on large headings.
15
+ - Avoid washed-out low-contrast gray text; strictly maintain WCAG AA contrast ratios.
16
+
17
+ 2. **Spacing & Layout Rhythm:**
18
+ - Strict 4px/8px spatial grid for all margins, padding, and gaps.
19
+ - Purposeful whitespace: group related elements tightly, separate distinct sections generously.
20
+ - Mobile-first responsiveness: fluid flex/grid layouts, no horizontal scroll overflows.
21
+
22
+ 3. **Color & Surface Depth:**
23
+ - Cohesive palette: 1 dominant background tone, subtle border/surface elevations, and 1 sharp accent color for key actions.
24
+ - Avoid flat grey boxes: use subtle borders (`1px solid rgba(...)`), soft layered shadows, or subtle gradients.
25
+
26
+ 4. **Interaction & Micro-details:**
27
+ - Polish interactive states on every control: hover, active, focus-visible, disabled, and loading.
28
+ - Smooth micro-interactions: quick transitions (150ms-250ms ease-out) for state changes.
29
+ - Complete states: always design empty states, error boundaries, and skeleton loaders.
30
+
31
+ ## Banned Patterns
32
+
33
+ - Pure `#000000` text on pure `#ffffff` backgrounds (use rich slate/zinc tones).
34
+ - Default browser focus rings (style distinct `:focus-visible`).
35
+ - Giant walls of unchunked text or cluttered dashboard cards.
36
+ - Centered body text longer than two lines.