# ca-setup > Set up Code Sentinel — register account, configure hooks and MCP server - Author: Archi - Repository: AndreyBegma/code-sentinel-pro - Version: 20260209214957 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-09 - Source: https://github.com/AndreyBegma/code-sentinel-pro - Web: https://mule.run/skillshub/@@AndreyBegma/code-sentinel-pro~ca-setup:20260209214957 --- --- name: ca-setup description: Set up Code Sentinel — register account, configure hooks and MCP server user-invocable: true allowed-tools: Read, Write, Edit, Bash, AskUserQuestion, Glob --- # /ca-setup — Plugin Setup One-command setup for Code Sentinel. Register account via web, then configure hooks and MCP server. ## Constants - `PLUGIN_DIR` — the directory containing this SKILL.md file (resolve `../../` from this file) - `SENTINEL_URL` — `https://code-sentinel.tech` - `CONFIG_DIR` — `~/.sentinel` - `CONFIG_PATH` — `~/.sentinel/config.json` - `HOOKS_PATH` — `~/.claude/hooks.json` - `MCP_PATH` — `~/.claude/.mcp.json` ## Steps ### Step 1 — Check existing config 1. Read `~/.sentinel/config.json` (if exists) 2. If `apiKey` is already set: - Verify it works via Bash: `curl -s -H "Authorization: Bearer $API_KEY" https://code-sentinel.tech/api/auth/verify` - If valid → tell user "Already configured as {email}" and ask via AskUserQuestion: - **Keep current config** (Recommended) — skip to Step 3 - **Set up with different account** — continue to Step 2 - If invalid → tell user "API key is invalid or expired" → continue to Step 2 ### Step 2 — Get API key 1. Show the user this message: ``` To use Code Sentinel, you need an account. Register here: https://code-sentinel.tech/register After registering, copy your API key and paste it below. ``` 2. Ask via AskUserQuestion with a single question: - Question: "Paste your API key (starts with sk-sentinel-)" - Options are not needed — user will type in "Other" 3. Validate the key format starts with `sk-sentinel-` 4. Verify the key works via Bash: ```bash curl -s -H "Authorization: Bearer API_KEY" https://code-sentinel.tech/api/auth/verify ``` 5. If invalid → tell user "Invalid API key. Please check and try /ca-setup again." → STOP 6. If valid → show "Authenticated as {email}" 7. Save config: - Bash: `mkdir -p ~/.sentinel` - Write `~/.sentinel/config.json`: ```json { "url": "https://code-sentinel.tech", "apiKey": "sk-sentinel-..." } ``` ### Step 3 — Build MCP server 1. Run via Bash: ```bash cd PLUGIN_DIR && npm install --ignore-scripts 2>&1 && npx tsc 2>&1 ``` 2. If build fails → show error and stop ### Step 4 — Register hooks 1. Read `~/.claude/hooks.json` (or start with `{}` if doesn't exist) 2. For each hook event, check if sentinel hooks are already registered (command contains "hook-session" or "hook-post-tool" or "hook-stop") 3. If not registered, add them. The final hooks.json should contain these sentinel entries merged with existing: ```json { "SessionStart": [{ "matcher": "", "hooks": [{"type": "command", "command": "node PLUGIN_DIR/scripts/hook-session-start.js", "timeout": 10000}] }], "PostToolUse": [{ "matcher": "", "hooks": [{"type": "command", "command": "node PLUGIN_DIR/scripts/hook-post-tool-use.js", "timeout": 5000}] }], "Stop": [{ "matcher": "", "hooks": [{"type": "command", "command": "node PLUGIN_DIR/scripts/hook-stop.js", "timeout": 30000}] }], "SubagentStop": [{ "matcher": "", "hooks": [{"type": "command", "command": "node PLUGIN_DIR/scripts/hook-session-end.js", "timeout": 30000}] }] } ``` IMPORTANT: Merge with existing hooks — do NOT overwrite other hooks. Only add sentinel entries if not already present. 4. Write the merged result to `~/.claude/hooks.json` ### Step 5 — Register MCP server 1. Read `~/.claude/.mcp.json` (or start with `{"mcpServers": {}}`) 2. Add/update the `sentinel-memory` entry: ```json { "mcpServers": { "sentinel-memory": { "command": "node", "args": ["PLUGIN_DIR/dist/mcp/server.js"], "env": { "SENTINEL_URL": "https://code-sentinel.tech", "SENTINEL_API_KEY": "THE_API_KEY" } } } } ``` IMPORTANT: Merge with existing MCP servers — do NOT overwrite other entries. 3. Write the merged result to `~/.claude/.mcp.json` ### Step 6 — Done Show summary: ``` ## Code Sentinel — Setup Complete! Server: https://code-sentinel.tech Account: {email} Config: ~/.sentinel/config.json What's configured: - 4 hooks registered in ~/.claude/hooks.json - MCP server registered in ~/.claude/.mcp.json **Restart Claude Code** to activate memory features. Available commands: - /ca-recall — search past findings - /ca-memory — memory stats and management - /ca-security, /ca-pr-review, etc. — all analysis skills ``` ## Error Handling - If server is unreachable → "Cannot connect to code-sentinel.tech. Check your internet connection." - If API key invalid → "Invalid API key. Register at https://code-sentinel.tech/register and try again." - If build fails → show the npm/tsc error output - If hooks.json is malformed → backup to `~/.claude/hooks.json.bak` and create fresh ## Notes - PLUGIN_DIR must be resolved as absolute path - All file writes use the Write tool (not Bash echo/cat) - All file reads use the Read tool - Never delete existing hooks or MCP servers from other plugins