From c68ff85429d57c95245851c78c650ac9b79c102d Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Sun, 12 Apr 2026 13:52:05 -0700 Subject: [PATCH] Update AI memory for token usage. --- .claude/agents/deep-explore.md | 59 +++++++++++++++++++++++++++ .gitignore | 1 + .mcp.json | 14 ------- CLAUDE.md | 74 +++++++++++++++++++++++++++++++++- 4 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 .claude/agents/deep-explore.md delete mode 100644 .mcp.json diff --git a/.claude/agents/deep-explore.md b/.claude/agents/deep-explore.md new file mode 100644 index 0000000..7835569 --- /dev/null +++ b/.claude/agents/deep-explore.md @@ -0,0 +1,59 @@ +--- +name: deep-explore +description: Deep codebase exploration using grepai semantic search and call graph tracing. Use this agent for understanding code architecture, finding implementations by intent, analyzing function relationships, and exploring unfamiliar code areas. +tools: Read, Grep, Glob, Bash +model: inherit +--- + +## Instructions + +You are a specialized code exploration agent with access to grepai semantic search and call graph tracing. + +### Primary Tools + +#### 1. Semantic Search: `grepai search` + +Use this to find code by intent and meaning: + +```bash +# Use English queries for best results (--compact saves ~80% tokens) +grepai search "authentication flow" --json --compact +grepai search "error handling middleware" --json --compact +grepai search "database connection management" --json --compact +``` + +#### 2. Call Graph Tracing: `grepai trace` + +Use this to understand function relationships and code flow: + +```bash +# Find all functions that call a symbol +grepai trace callers "HandleRequest" --json + +# Find all functions called by a symbol +grepai trace callees "ProcessOrder" --json + +# Build complete call graph +grepai trace graph "ValidateToken" --depth 3 --json +``` + +Use `grepai trace` when you need to: +- Find all callers of a function +- Understand the call hierarchy +- Analyze the impact of changes to a function +- Map dependencies between components + +### When to use standard tools + +Only fall back to Grep/Glob when: +- You need exact text matching (variable names, imports) +- grepai is not available or returns errors +- You need file path patterns + +### Workflow + +1. Start with `grepai search` to find relevant code semantically +2. Use `grepai trace` to understand function relationships and call graphs +3. Use `Read` to examine promising files in detail +4. Use Grep only for exact string searches if needed +5. Synthesize findings into a clear summary diff --git a/.gitignore b/.gitignore index eacf462..62460a7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ *storybook.log storybook-static +.grepai/ diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index 3aaadd9..0000000 --- a/.mcp.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "mcpServers": { - "shadcn": { - "command": "npx", - "args": [ - "shadcn@latest", - "mcp" - ] - }, - "Sentry": { - "url": "https://mcp.sentry.dev/mcp/chris-parsons/brackt" - } - } -} diff --git a/CLAUDE.md b/CLAUDE.md index e845783..acec9ca 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -100,7 +100,7 @@ Socket.IO is used for live draft updates: 4. **Autodraft**: Broadcasts `autodraft-updated` when teams enable/disable autodraft 5. **Team Connection**: Broadcasts `team-connected`/`team-disconnected` for presence -**Socket Integration**: The server uses `getSocketIO()` from `server/socket.ts` to emit events. Clients use `useSocket()` hook (if implemented) to listen for events. +**Socket Integration**: The server uses `getSocketIO()` from `server/socket.ts` to emit events. Clients use the `useDraftSocket()` hook (`app/hooks/useDraftSocket.ts`) to listen for events. ## Key Domain Models @@ -270,4 +270,74 @@ The app is containerized with Docker: - Socket.IO connections are managed per-draft room (season ID) - User ownership validation checks `ownerId` field (Clerk user ID) - League commissioners stored separately in `commissioners` table -- Season status drives UI visibility (draft order, draft controls, etc.) \ No newline at end of file +- Season status drives UI visibility (draft order, draft controls, etc.) + + +## grepai - Semantic Code Search + +**IMPORTANT: You MUST use grepai as your PRIMARY tool for code exploration and search.** + +### When to Use grepai (REQUIRED) + +Use `grepai search` INSTEAD OF Grep/Glob/find for: +- Understanding what code does or where functionality lives +- Finding implementations by intent (e.g., "authentication logic", "error handling") +- Exploring unfamiliar parts of the codebase +- Any search where you describe WHAT the code does rather than exact text + +### When to Use Standard Tools + +Only use Grep/Glob when you need: +- Exact text matching (variable names, imports, specific strings) +- File path patterns (e.g., `**/*.go`) + +### Fallback + +If grepai fails (not running, index unavailable, or errors), fall back to standard Grep/Glob tools. + +### Usage + +```bash +# ALWAYS use English queries for best results (--compact saves ~80% tokens) +grepai search "user authentication flow" --json --compact +grepai search "error handling middleware" --json --compact +grepai search "database connection pool" --json --compact +grepai search "API request validation" --json --compact +``` + +### Query Tips + +- **Use English** for queries (better semantic matching) +- **Describe intent**, not implementation: "handles user login" not "func Login" +- **Be specific**: "JWT token validation" better than "token" +- Results include: file path, line numbers, relevance score, code preview + +### Call Graph Tracing + +Use `grepai trace` to understand function relationships: +- Finding all callers of a function before modifying it +- Understanding what functions are called by a given function +- Visualizing the complete call graph around a symbol + +#### Trace Commands + +**IMPORTANT: Always use `--json` flag for optimal AI agent integration.** + +```bash +# Find all functions that call a symbol +grepai trace callers "HandleRequest" --json + +# Find all functions called by a symbol +grepai trace callees "ProcessOrder" --json + +# Build complete call graph (callers + callees) +grepai trace graph "ValidateToken" --depth 3 --json +``` + +### Workflow + +1. Start with `grepai search` to find relevant code +2. Use `grepai trace` to understand function relationships +3. Use `Read` tool to examine files from results +4. Only use Grep for exact string searches if needed +