#!/bin/bash # # Claude Enforcer Installer # Installs the skill-builder skill to your Claude Code project # # Usage: # bash -c "$(curl -fsSL https://raw.githubusercontent.com/odysseyalive/claude-enforcer/main/install)" # set -e REPO_URL="https://raw.githubusercontent.com/odysseyalive/claude-enforcer/main" SKILL_DIR=".claude/skills/skill-builder" echo "Claude Enforcer Installer" echo "=========================" echo # Check for CLAUDE.md in current directory if [ ! -f "CLAUDE.md" ]; then echo "Error: CLAUDE.md not found in current directory." echo echo "This installer must be run from a Claude Code project root." echo "If you haven't initialized Claude Code yet, run:" echo echo " claude /init" echo echo "Then run this installer again." exit 1 fi echo "Found CLAUDE.md in $(pwd)" # Remove legacy files from prior installer versions # (older installs shipped these; they've since been removed from the skill) for legacy in \ "$SKILL_DIR/reference.md" \ "$SKILL_DIR/references/procedures.md" \ "$SKILL_DIR/references/self-heal-templates.md" \ "$SKILL_DIR/references/procedures/self-heal.md"; do if [ -f "$legacy" ]; then echo "Removing legacy $(basename "$legacy")..." rm -f "$legacy" fi done # Remove legacy standalone shell-safety skill (now absorbed into skill-builder) if [ -d ".claude/skills/shell-safety" ]; then echo "Removing legacy shell-safety skill (now a skill-builder subcommand)..." rm -rf ".claude/skills/shell-safety" fi # Remove legacy distributed hook scripts. skill-builder no longer ships hooks; # enforcement is via in-SKILL.md CHECKPOINTs (cross-platform, code-free). # Users who want enforcement hooks for their own skills generate them at runtime # via `/skill-builder hooks [skill] --execute`. if [ -d "$SKILL_DIR/hooks" ]; then echo "Removing legacy skill-builder hook scripts (no longer distributed)..." rm -rf "$SKILL_DIR/hooks" fi # Create skill directory (preserves existing to avoid breaking active sessions) echo "Creating $SKILL_DIR..." mkdir -p "$SKILL_DIR/references/procedures" mkdir -p "$SKILL_DIR/references/shell-safety" mkdir -p "$SKILL_DIR/agents/optimize-diff-auditor" mkdir -p "$SKILL_DIR/agents/intent-router" # Download SKILL.md and reference files echo "Downloading skill-builder..." curl -fsSL "$REPO_URL/skill-builder/SKILL.md" -o "$SKILL_DIR/SKILL.md" for ref in agents agents-personas agents-teams enforcement eval-history-format eval-rubrics ledger-templates optimization-examples patterns platform portability principles templates temporal-validation token-efficiency; do curl -fsSL "$REPO_URL/skill-builder/references/${ref}.md" -o "$SKILL_DIR/references/${ref}.md" done for proc in audit verify quick-audit skills list optimize agents hooks new strip directives inline post-action-chain claude-md ledger cascade eval checksums convert shell-safety intent-router route; do curl -fsSL "$REPO_URL/skill-builder/references/procedures/${proc}.md" -o "$SKILL_DIR/references/procedures/${proc}.md" done for ss in rules templates audit-patterns; do curl -fsSL "$REPO_URL/skill-builder/references/shell-safety/${ss}.md" -o "$SKILL_DIR/references/shell-safety/${ss}.md" done curl -fsSL "$REPO_URL/skill-builder/agents/optimize-diff-auditor/AGENT.md" -o "$SKILL_DIR/agents/optimize-diff-auditor/AGENT.md" curl -fsSL "$REPO_URL/skill-builder/agents/intent-router/AGENT.md" -o "$SKILL_DIR/agents/intent-router/AGENT.md" # Enable agent teams and auto-approve research tools SETTINGS_FILE=".claude/settings.local.json" echo "Configuring project settings..." if command -v python3 &>/dev/null; then python3 -c " import json, os p = '$SETTINGS_FILE' d = json.load(open(p)) if os.path.exists(p) else {} changed = False # Enable agent teams if d.get('env', {}).get('CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS') != '1': d.setdefault('env', {})['CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS'] = '1' changed = True print(' Agent teams enabled') else: print(' Agent teams already enabled') # Auto-approve web research tools (belt — permissions layer) # The suspenders (PreToolUse hook) are generated per-system by /skill-builder hooks research_tools = [ 'WebSearch', 'WebFetch', 'mcp__jina__read_url', 'mcp__jina__search_web', 'mcp__jina__parallel_read_url', 'mcp__jina__parallel_search_web', ] allow = d.setdefault('permissions', {}).setdefault('allow', []) for tool in research_tools: if tool not in allow: allow.append(tool) changed = True print(f' Added {tool} to permissions.allow') else: print(f' {tool} already in permissions.allow') if changed: json.dump(d, open(p, 'w'), indent=2) print(f' Settings saved to $SETTINGS_FILE') " else echo " Warning: python3 not found. Add these to $SETTINGS_FILE manually:" echo ' { "env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" },' echo ' "permissions": { "allow": ["WebSearch", "WebFetch", "mcp__jina__read_url", "mcp__jina__search_web", "mcp__jina__parallel_read_url", "mcp__jina__parallel_search_web"] } }' fi echo echo "Installation complete." echo echo "Usage:" echo " /skill-builder Full audit (display mode)" echo " /skill-builder optimize [skill] Show optimization plan (--execute to apply)" echo " /skill-builder agents [skill] Show agent opportunities (--execute to create)" echo " /skill-builder hooks [skill] Show hooks inventory (--execute to create)" echo " /skill-builder shell-safety lint [file] Check shell or settings.json for pitfalls" echo " /skill-builder shell-safety audit [path] Scan and patch fragility (--execute to fix)" echo " /skill-builder route index Build /route skill index (auto-runs at audit end)" echo " /skill-builder route embed Plan route consultation gates (--execute to apply)" echo