Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
One-time setup that gathers your project's design context and saves it to CLAUDE.md for future sessions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/hook.mjs
1#!/usr/bin/env node2/**3* Impeccable design hook — PostToolUse entry point.4*5* Reads the Claude Code / Codex / Cursor hook event from stdin, runs the design6* detector against the touched file, and emits a system reminder via7* `hookSpecificOutput.additionalContext` when findings exist.8*9* Contract: never break a turn. Always exit 0. Clean files emit a small ack10* unless quiet mode is enabled.11*12* Most logic lives in `hook-lib.mjs` so it is unit-testable without a13* subprocess. This file is the thin stdin/stdout adapter.14*/1516import { runHook, writeAuditLog } from './hook-lib.mjs';1718async function readStdin() {19if (process.stdin.isTTY) return '';20const chunks = [];21for await (const chunk of process.stdin) chunks.push(chunk);22return Buffer.concat(chunks).toString('utf-8');23}2425async function main() {26// Snapshot the inherited env FIRST so the re-entrancy guard checks the27// parent's value, not the value we are about to export for any child28// processes the hook might ever spawn.29const inheritedEnv = { ...process.env };30process.env.IMPECCABLE_HOOK_DEPTH = process.env.IMPECCABLE_HOOK_DEPTH || '1';3132let stdinJson = '';33try { stdinJson = await readStdin(); } catch { /* fall through */ }3435const result = await runHook({36stdinJson,37env: inheritedEnv,38cwd: process.cwd(),39});4041writeAuditLog(process.env, result.audit, process.cwd());4243if (result.stdout) process.stdout.write(result.stdout);44process.exit(result.exitCode || 0);45}4647main().catch((err) => {48// Last-ditch: never break the agent's turn even if something we did not49// anticipate goes wrong. Audit-log the failure if logging is enabled.50try {51writeAuditLog(process.env, {52ts: new Date().toISOString(),53event: 'PostToolUse',54error: String(err && err.message ? err.message : err),55});56} catch { /* swallow */ }57if (process.env.IMPECCABLE_HOOK_DEBUG) {58process.stderr.write(`[impeccable-hook] ${err}\n`);59}60process.exit(0);61});62