Add install.sh — global Claude Code setup for Developer Intelligence

- Installs MCP config to ~/.claude/mcp.json (merges with existing)
- Appends knowledge graph instructions to ~/.claude/CLAUDE.md
- Run once, works in any repo after that
This commit is contained in:
Jarvis Prime
2026-03-04 04:40:40 +00:00
parent 65e114a5d6
commit 4acb057042

81
install.sh Executable file
View File

@@ -0,0 +1,81 @@
#!/usr/bin/env bash
# install.sh — Install Developer Intelligence globally for Claude Code.
# Run once. Works in any repo after that.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CLAUDE_DIR="$HOME/.claude"
mkdir -p "$CLAUDE_DIR"
# Install global MCP config
# Merge with existing if present
MCP_FILE="$CLAUDE_DIR/mcp.json"
if [ -f "$MCP_FILE" ]; then
echo "[install] Existing mcp.json found — merging..."
python3 -c "
import json, sys
existing = json.load(open('$MCP_FILE'))
existing.setdefault('mcpServers', {})
existing['mcpServers']['dev-intel'] = {
'command': 'uv',
'args': ['run', 'python', 'mcp_server.py'],
'cwd': '$SCRIPT_DIR'
}
json.dump(existing, open('$MCP_FILE', 'w'), indent=2)
print(' Added dev-intel to existing mcp.json')
"
else
cat > "$MCP_FILE" << EOF
{
"mcpServers": {
"dev-intel": {
"command": "uv",
"args": ["run", "python", "mcp_server.py"],
"cwd": "$SCRIPT_DIR"
}
}
}
EOF
echo "[install] Created $MCP_FILE"
fi
# Install global CLAUDE.md (append if exists)
CLAUDE_MD="$CLAUDE_DIR/CLAUDE.md"
MARKER="## Developer Intelligence Knowledge Graph"
if [ -f "$CLAUDE_MD" ] && grep -q "$MARKER" "$CLAUDE_MD"; then
echo "[install] Developer Intelligence already in $CLAUDE_MD — skipping."
else
cat >> "$CLAUDE_MD" << 'EOF'
## Developer Intelligence Knowledge Graph
This environment has access to a knowledge graph of LLM-generated documentation for your codebase via MCP tools.
**Always prefer the knowledge graph over reading raw files when answering questions about what code does or how files interact.**
### Query patterns
- "What does X do?" → `get_file_doc("path/to/file.go")`
- "How do X and Y interact?" → `get_relationship("file_a.go", "file_b.go")`
- "What's this project about?" → `get_repo_overview()`
- "What depends on X?" / "What breaks if I change X?" → `get_dependents("path/to/file.go")`
- "What does X depend on?" → `get_dependencies("path/to/file.go")`
- "Find anything about routing" → `search_docs("routing")`
- "What's outdated?" → `get_stale_docs()`
### Staleness
Docs flagged `[STALE]` mean the code changed but the doc hasn't been regenerated yet. Mention this to the user.
### Tips
- Start broad (`get_repo_overview`) then drill into specifics.
- `get_dependents` is impact analysis — "what breaks if I change this?"
- File paths are relative to repo root (e.g., `echo.go`, `middleware/compress.go`).
EOF
echo "[install] Appended Developer Intelligence instructions to $CLAUDE_MD"
fi
echo ""
echo "[install] Done. Developer Intelligence is now available in all Claude Code sessions."
echo "[install] Run 'claude' from any repo directory — the knowledge graph tools are global."