Skip to content

oprogramadorreal/optimus-claude / skills/init

Bootstraps a project for Claude Code or Codex — generates routed project guidance from detected structure, reconciles existing docs, and offers test infrastructure. Claude Code can also install formatter hooks. Writes .claude/, CLAUDE.md, AGENTS.md and subproject docs/; may append to README/.gitignore and, with approval, install dev dependencies. Preserves existing guidance through review and recorded ownership. Use for initial setup or upgrades.

templates/hooks/format-node.cjs

View on GitHub
/**
 * PostToolUse hook: run prettier on web files after Edit/MultiEdit/Write.
 * Walks up from the file to find the nearest node_modules with prettier,
 * so it works in both single projects and monorepos without workspaces.
 */
const { readFileSync, existsSync } = require('fs');
const { execFileSync } = require('child_process');
const path = require('path');

const data = JSON.parse(readFileSync(0, 'utf8'));
const inputPath = (data.tool_input || {}).file_path || '';
if (typeof inputPath !== 'string' || !inputPath) process.exit(0);
const filePath = path.resolve(inputPath);

const exts = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.mts', '.cts', '.vue', '.svelte', '.astro', '.css', '.scss', '.html', '.json', '.yaml', '.yml', '.graphql'];
if (!exts.some(ext => filePath.endsWith(ext))) process.exit(0);

let dir = path.dirname(path.resolve(filePath));
while (dir !== path.dirname(dir)) {
  if (existsSync(path.join(dir, 'node_modules', 'prettier'))) {
    try {
      const pkgPath = path.join(dir, 'node_modules', 'prettier', 'package.json');
      const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
      const binEntry = typeof pkg.bin === 'string' ? pkg.bin : (pkg.bin || {}).prettier;
      if (!binEntry) break;
      const cli = path.resolve(dir, 'node_modules', 'prettier', binEntry);
      // An argv array keeps shell metacharacters and Windows %VAR% paths literal.
      execFileSync(process.execPath, [cli, '--write', '--log-level', 'silent', filePath], {
        cwd: dir,
        stdio: ['pipe', 'pipe', 'pipe'],
      });
    } catch (err) {
      const stderr = (err.stderr || Buffer.alloc(0)).toString().trim();
      const msg = stderr.split('\n')[0] || `exit code ${err.status}`;
      process.stderr.write(`[format-node] prettier failed: ${msg}\n`);
    }
    break;
  }
  dir = path.dirname(dir);
}
// Only a walk that never found prettier ends at the filesystem root.
if (dir === path.dirname(dir)) {
  process.stderr.write('[format-node] prettier not found in node_modules above the file — skipped.\n');
}
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 321kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 321kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 321kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall