|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +if [ -t 1 ]; then |
| 5 | + GREEN='\033[32m' |
| 6 | + DIM='\033[2m' |
| 7 | + RESET='\033[0m' |
| 8 | +else |
| 9 | + GREEN='' |
| 10 | + DIM='' |
| 11 | + RESET='' |
| 12 | +fi |
| 13 | + |
| 14 | +SKILL_NAME="react-doctor" |
| 15 | +INSTALLED=0 |
| 16 | + |
| 17 | +SKILL_CONTENT=$(cat << 'EOF' |
| 18 | +--- |
| 19 | +name: react-doctor |
| 20 | +description: Diagnose and fix React codebase health issues. Use when reviewing React code, fixing performance problems, auditing security, or improving code quality. |
| 21 | +version: 1.0.0 |
| 22 | +--- |
| 23 | +
|
| 24 | +# React Doctor |
| 25 | +
|
| 26 | +Scans your React codebase for security, performance, correctness, and architecture issues. Outputs a 0-100 score with actionable diagnostics. |
| 27 | +
|
| 28 | +## Usage |
| 29 | +
|
| 30 | +```bash |
| 31 | +npx -y react-doctor@latest . --verbose --diff |
| 32 | +``` |
| 33 | +
|
| 34 | +## Workflow |
| 35 | +
|
| 36 | +Run after making changes to catch issues early. Fix errors first, then re-run to verify the score improved. |
| 37 | +EOF |
| 38 | +) |
| 39 | + |
| 40 | +AGENTS_CONTENT=$(cat << 'EOF' |
| 41 | +# React Doctor |
| 42 | +
|
| 43 | +Diagnose and fix React codebase health issues. Use when reviewing React code, fixing performance problems, auditing security, or improving code quality. |
| 44 | +
|
| 45 | +Scans your React codebase for security, performance, correctness, and architecture issues. Outputs a 0-100 score with actionable diagnostics. |
| 46 | +
|
| 47 | +## Usage |
| 48 | +
|
| 49 | +```bash |
| 50 | +npx -y react-doctor@latest . --verbose --diff |
| 51 | +``` |
| 52 | +
|
| 53 | +## Workflow |
| 54 | +
|
| 55 | +Run after making changes to catch issues early. Fix errors first, then re-run to verify the score improved. |
| 56 | +EOF |
| 57 | +) |
| 58 | + |
| 59 | +echo "Installing React Doctor skill..." |
| 60 | +echo "" |
| 61 | + |
| 62 | +# Claude Code |
| 63 | +if [ -d "$HOME/.claude" ]; then |
| 64 | + SKILL_DIR="$HOME/.claude/skills/$SKILL_NAME" |
| 65 | + mkdir -p "$SKILL_DIR" |
| 66 | + printf '%s\n' "$SKILL_CONTENT" > "$SKILL_DIR/SKILL.md" |
| 67 | + printf '%s\n' "$AGENTS_CONTENT" > "$SKILL_DIR/AGENTS.md" |
| 68 | + printf "${GREEN}✔${RESET} Claude Code\n" |
| 69 | + INSTALLED=$((INSTALLED + 1)) |
| 70 | +fi |
| 71 | + |
| 72 | +# Amp Code |
| 73 | +if [ -d "$HOME/.amp" ]; then |
| 74 | + SKILL_DIR="$HOME/.config/amp/skills/$SKILL_NAME" |
| 75 | + mkdir -p "$SKILL_DIR" |
| 76 | + printf '%s\n' "$SKILL_CONTENT" > "$SKILL_DIR/SKILL.md" |
| 77 | + printf '%s\n' "$AGENTS_CONTENT" > "$SKILL_DIR/AGENTS.md" |
| 78 | + printf "${GREEN}✔${RESET} Amp Code\n" |
| 79 | + INSTALLED=$((INSTALLED + 1)) |
| 80 | +fi |
| 81 | + |
| 82 | +# Cursor |
| 83 | +if [ -d "$HOME/.cursor" ]; then |
| 84 | + SKILL_DIR="$HOME/.cursor/skills/$SKILL_NAME" |
| 85 | + mkdir -p "$SKILL_DIR" |
| 86 | + printf '%s\n' "$SKILL_CONTENT" > "$SKILL_DIR/SKILL.md" |
| 87 | + printf '%s\n' "$AGENTS_CONTENT" > "$SKILL_DIR/AGENTS.md" |
| 88 | + printf "${GREEN}✔${RESET} Cursor\n" |
| 89 | + INSTALLED=$((INSTALLED + 1)) |
| 90 | +fi |
| 91 | + |
| 92 | +# OpenCode |
| 93 | +if command -v opencode &> /dev/null || [ -d "$HOME/.config/opencode" ]; then |
| 94 | + SKILL_DIR="$HOME/.config/opencode/skills/$SKILL_NAME" |
| 95 | + mkdir -p "$SKILL_DIR" |
| 96 | + printf '%s\n' "$SKILL_CONTENT" > "$SKILL_DIR/SKILL.md" |
| 97 | + printf '%s\n' "$AGENTS_CONTENT" > "$SKILL_DIR/AGENTS.md" |
| 98 | + printf "${GREEN}✔${RESET} OpenCode\n" |
| 99 | + INSTALLED=$((INSTALLED + 1)) |
| 100 | +fi |
| 101 | + |
| 102 | +# Windsurf |
| 103 | +MARKER="# React Doctor" |
| 104 | +if [ -d "$HOME/.codeium" ] || [ -d "$HOME/Library/Application Support/Windsurf" ]; then |
| 105 | + mkdir -p "$HOME/.codeium/windsurf/memories" |
| 106 | + RULES_FILE="$HOME/.codeium/windsurf/memories/global_rules.md" |
| 107 | + if [ -f "$RULES_FILE" ] && grep -q "$MARKER" "$RULES_FILE"; then |
| 108 | + printf "${GREEN}✔${RESET} Windsurf ${DIM}(already installed)${RESET}\n" |
| 109 | + else |
| 110 | + if [ -f "$RULES_FILE" ]; then |
| 111 | + echo "" >> "$RULES_FILE" |
| 112 | + fi |
| 113 | + echo "$MARKER" >> "$RULES_FILE" |
| 114 | + echo "" >> "$RULES_FILE" |
| 115 | + printf '%s\n' "$SKILL_CONTENT" >> "$RULES_FILE" |
| 116 | + printf "${GREEN}✔${RESET} Windsurf\n" |
| 117 | + fi |
| 118 | + INSTALLED=$((INSTALLED + 1)) |
| 119 | +fi |
| 120 | + |
| 121 | +# Antigravity |
| 122 | +if command -v agy &> /dev/null || [ -d "$HOME/.gemini/antigravity" ]; then |
| 123 | + SKILL_DIR="$HOME/.gemini/antigravity/skills/$SKILL_NAME" |
| 124 | + mkdir -p "$SKILL_DIR" |
| 125 | + printf '%s\n' "$SKILL_CONTENT" > "$SKILL_DIR/SKILL.md" |
| 126 | + printf '%s\n' "$AGENTS_CONTENT" > "$SKILL_DIR/AGENTS.md" |
| 127 | + printf "${GREEN}✔${RESET} Antigravity\n" |
| 128 | + INSTALLED=$((INSTALLED + 1)) |
| 129 | +fi |
| 130 | + |
| 131 | +# Gemini CLI |
| 132 | +if command -v gemini &> /dev/null || [ -d "$HOME/.gemini" ]; then |
| 133 | + mkdir -p "$HOME/.gemini/skills/$SKILL_NAME" |
| 134 | + printf '%s\n' "$SKILL_CONTENT" > "$HOME/.gemini/skills/$SKILL_NAME/SKILL.md" |
| 135 | + printf '%s\n' "$AGENTS_CONTENT" > "$HOME/.gemini/skills/$SKILL_NAME/AGENTS.md" |
| 136 | + printf "${GREEN}✔${RESET} Gemini CLI\n" |
| 137 | + INSTALLED=$((INSTALLED + 1)) |
| 138 | +fi |
| 139 | + |
| 140 | +# Codex |
| 141 | +if command -v codex &> /dev/null || [ -d "$HOME/.codex" ]; then |
| 142 | + SKILL_DIR="$HOME/.codex/skills/$SKILL_NAME" |
| 143 | + mkdir -p "$SKILL_DIR" |
| 144 | + mkdir -p "$SKILL_DIR/agents" |
| 145 | + printf '%s\n' "$SKILL_CONTENT" > "$SKILL_DIR/SKILL.md" |
| 146 | + printf '%s\n' "$AGENTS_CONTENT" > "$SKILL_DIR/AGENTS.md" |
| 147 | + cat > "$SKILL_DIR/agents/openai.yaml" << 'YAMLEOF' |
| 148 | +interface: |
| 149 | + display_name: "react-doctor" |
| 150 | + short_description: "Diagnose and fix React codebase health issues" |
| 151 | +YAMLEOF |
| 152 | + printf "${GREEN}✔${RESET} Codex\n" |
| 153 | + INSTALLED=$((INSTALLED + 1)) |
| 154 | +fi |
| 155 | + |
| 156 | +# Project-level .agents/ |
| 157 | +AGENTS_DIR=".agents/$SKILL_NAME" |
| 158 | +mkdir -p "$AGENTS_DIR" |
| 159 | +printf '%s\n' "$SKILL_CONTENT" > "$AGENTS_DIR/SKILL.md" |
| 160 | +printf '%s\n' "$AGENTS_CONTENT" > "$AGENTS_DIR/AGENTS.md" |
| 161 | +printf "${GREEN}✔${RESET} .agents/\n" |
| 162 | +INSTALLED=$((INSTALLED + 1)) |
| 163 | + |
| 164 | +echo "" |
| 165 | +if [ $INSTALLED -eq 0 ]; then |
| 166 | + echo "No supported tools detected." |
| 167 | + echo "" |
| 168 | + echo "Install one of these first:" |
| 169 | + echo " • Ami: https://ami.dev" |
| 170 | + echo " • Amp Code: https://ampcode.com" |
| 171 | + echo " • Antigravity: https://antigravity.google" |
| 172 | + echo " • Claude Code: https://claude.ai/code" |
| 173 | + echo " • Codex: https://codex.openai.com" |
| 174 | + echo " • Cursor: https://cursor.com" |
| 175 | + echo " • Gemini CLI: https://github.com/google-gemini/gemini-cli" |
| 176 | + echo " • OpenCode: https://opencode.ai" |
| 177 | + echo " • Windsurf: https://codeium.com/windsurf" |
| 178 | + exit 1 |
| 179 | +fi |
| 180 | + |
| 181 | +echo "Done! The skill will activate when working on React projects." |
0 commit comments