diff --git a/README.md b/README.md index 05e1842..230bc31 100644 --- a/README.md +++ b/README.md @@ -47,29 +47,29 @@ The database is automatically created at `.code_search/surrealdb.rocksdb` in you Import a call graph JSON file (generated by [ex_ast](https://github.com/CamonZ/ex_ast)): ```bash -code_search import --file call_graph.json +code_search code import --file call_graph.json ``` ### 3. Query the data ```bash # Find where a function is defined -code_search location get_user MyApp.Accounts +code_search code location get_user MyApp.Accounts # What does this function call? -code_search calls-from MyApp.Accounts get_user +code_search code calls-from MyApp.Accounts get_user # Who calls this function? -code_search calls-to MyApp.Repo get +code_search code calls-to MyApp.Repo get # Trace the full call chain from a function -code_search trace MyApp.Web.UserController show +code_search code trace MyApp.Web.UserController show # Find unused functions -code_search unused -P +code_search code unused -P # Find hotspots (most called functions) -code_search hotspots -l 10 +code_search code hotspots -l 10 ``` ## Output Formats @@ -82,7 +82,7 @@ All commands support three output formats via `--format` or `-o`: ## Commands -Use `code_search --help` for detailed help on any command. +Use `code_search code --help` for detailed help on any command. ### Query Commands @@ -169,26 +169,26 @@ If `--db` is not specified, commands automatically search for the database in th ```bash # Find all functions that accept a User.t type -code_search accepts "User.t" +code_search code accepts "User.t" # Find modules with circular dependencies -code_search cycles MyApp.Core +code_search code cycles MyApp.Core # Find the most complex functions in a namespace -code_search complexity MyApp.Accounts --min 10 +code_search code complexity MyApp.Accounts --min 10 # Trace how a controller action flows through the codebase -code_search trace MyApp.Web.UserController create --depth 10 +code_search code trace MyApp.Web.UserController create --depth 10 # Find all paths from an API endpoint to a database call -code_search path --from-module MyApp.API --from-function create_user \ +code_search code path --from-module MyApp.API --from-function create_user \ --to-module MyApp.Repo --to-function insert # Find god modules (too large, too connected) -code_search god-modules --min-functions 30 --min-loc 500 +code_search code god-modules --min-functions 30 --min-loc 500 # Find boundary modules that many depend on -code_search boundaries --min-ratio 3.0 +code_search code boundaries --min-ratio 3.0 ``` ## Claude Code Integration @@ -234,6 +234,22 @@ git config code-search.mix-env test # Default: dev See [docs/GIT_HOOKS.md](docs/GIT_HOOKS.md) for detailed documentation and troubleshooting. +### Git Worktrees + +When using [git worktrees](https://git-scm.com/docs/git-worktree), each +worktree must have its own local database. Run setup and import once in +each worktree directory: + +```sh +mix compile +ex_ast --output /tmp/call_graph.json +code_search setup +code_search code import --file /tmp/call_graph.json +``` + +See [docs/WORKTREES.md](docs/WORKTREES.md) for full details and +troubleshooting. + ### Using with Claude Code Once templates are installed, Claude Code can automatically help you explore your codebase: diff --git a/docs/GIT_HOOKS.md b/docs/GIT_HOOKS.md index 3a3924a..b204b99 100644 --- a/docs/GIT_HOOKS.md +++ b/docs/GIT_HOOKS.md @@ -81,7 +81,7 @@ When you make a commit, the post-commit hook: - Uses the configured Mix environment - Outputs JSON to a temporary file -4. **Updates database**: Runs `code_search import` to update the database +4. **Updates database**: Runs `code_search code import` to update the database - Database path auto-resolves to `.code_search/surrealdb.rocksdb` - Uses configured project name if set (optional) - Performs upsert operations (updates existing records, inserts new ones) @@ -224,7 +224,7 @@ mix compile --debug-info ex_ast --git-diff HEAD~1 --format json --output changes.json # Import -code_search --db call_graph.db import --file changes.json +code_search --db call_graph.db code import --file changes.json ``` Or for a different git reference: @@ -246,7 +246,7 @@ The same approach works in CI/CD pipelines. Example GitHub Actions workflow: run: | mix compile --debug-info ex_ast --git-diff HEAD~1 --format json --output changes.json - code_search --db call_graph.db import --file changes.json + code_search --db call_graph.db code import --file changes.json ``` ## Performance Characteristics diff --git a/docs/NEW_COMMANDS.md b/docs/NEW_COMMANDS.md index 0585982..57104cc 100644 --- a/docs/NEW_COMMANDS.md +++ b/docs/NEW_COMMANDS.md @@ -56,7 +56,7 @@ use crate::output::{OutputFormat, Outputable}; #[derive(Args, Debug)] #[command(after_help = "\ Examples: - code_search --arg value # Example usage")] + code_search code --arg value # Example usage")] pub struct Cmd { /// Description of the argument #[arg(short, long)] @@ -148,9 +148,9 @@ impl Outputable for Result { See [examples/output_tests.rs.example](./examples/output_tests.rs.example) for a reference showing the snapshot testing pattern. The example includes a helper for generating the actual output values to use in your snapshots. -### 8. Register the command (`src/commands/mod.rs`) +### 8. Register the command -Add the module declaration and public export: +Add the module declaration and public export in `src/commands/mod.rs`: ```rust mod ; @@ -158,24 +158,21 @@ mod ; pub use ::Cmd; ``` -Add the variant to the `Command` enum: +Add the variant to the `CodeCommand` enum in `src/commands/code.rs`: ```rust #[derive(Subcommand, Debug)] #[enum_dispatch(CommandRunner)] -pub enum Command { +pub enum CodeCommand { /// Existing commands... Import(ImportCmd), /// Description of your command (Cmd), - - #[command(external_subcommand)] - Unknown(Vec), } ``` -**Note:** The `#[enum_dispatch(CommandRunner)]` attribute is already on the `Command` enum. The `enum_dispatch` crate automatically generates the dispatch logic for all variants. You do NOT need to add a match arm in `Command::run()` - the `CommandRunner` implementation you added to your command's `mod.rs` file (in step 2) is all that's needed! +**Note:** The top-level `Command` enum in `mod.rs` has only `Setup` and `Code(CodeCommand)`. All code analysis commands are registered in `CodeCommand` (in `code.rs`), not in `Command`. The `#[enum_dispatch(CommandRunner)]` attribute automatically generates dispatch logic for all variants. You do NOT need to add a match arm — the `CommandRunner` implementation you added to your command's `mod.rs` file (in step 2) is all that's needed! The dispatch is handled entirely by the `enum_dispatch` procedural macro at compile time, which is faster and more maintainable than manual match arms. @@ -184,7 +181,7 @@ The dispatch is handled entirely by the `enum_dispatch` procedural macro at comp ```bash cargo build cargo test -cargo run -- --help +cargo run -- code --help ``` ## Checklist @@ -219,7 +216,7 @@ cargo run -- --help - [ ] Registered command in `src/commands/mod.rs` - [ ] Added module declaration: `mod ;` - [ ] Added public export: `pub use ::Cmd;` - - [ ] Added enum variant to `Command` enum (dispatch is automatic via `#[enum_dispatch(CommandRunner)]`) +- [ ] Added enum variant to `CodeCommand` in `src/commands/code.rs` (dispatch is automatic via `#[enum_dispatch(CommandRunner)]`) - [ ] **No match arm needed** - enum_dispatch handles it automatically! - [ ] Verified with `cargo build && cargo test` diff --git a/docs/WORKTREES.md b/docs/WORKTREES.md new file mode 100644 index 0000000..82132c2 --- /dev/null +++ b/docs/WORKTREES.md @@ -0,0 +1,51 @@ +# Using code_search with Git Worktrees + +Each worktree must have its own local database. The tool uses an embedded +RocksDB which only allows one process to hold the lock at a time — if multiple +worktrees share the global `~/.code_search/surrealdb.rocksdb` you will get: + +``` +Error: "Failed to connect to SurrealDB: IO error: While lock file: LOCK: +Resource temporarily unavailable" +``` + +## Setup per worktree + +Run this once in each worktree root: + +```sh +mix compile +ex_ast --output /tmp/call_graph.json +code_search setup +code_search code import --file /tmp/call_graph.json +rm /tmp/call_graph.json +``` + +`code_search setup` creates `.code_search/surrealdb.rocksdb` in the current +directory. The tool's path resolution always prefers a local `.code_search/` +over the global `~/.code_search/`, so each worktree gets its own isolated +database and lock file. + +## Rebuilding a stale or corrupt database + +If you see a "record already exists" or lock error on a worktree that already +has a local DB: + +```sh +rm -rf .code_search/surrealdb.rocksdb +mix compile +ex_ast --output /tmp/call_graph.json +code_search setup +code_search code import --file /tmp/call_graph.json +rm /tmp/call_graph.json +``` + +## Important notes + +- Never rely on `~/.code_search/surrealdb.rocksdb` in a multi-worktree setup +- Two processes cannot share the same RocksDB — this is an embedded database + limitation, not a bug in code_search +- Each worktree's `.code_search/` should be in `.gitignore` (it is by default) +- The git hook installed via `code_search setup --install-hooks` handles + incremental updates automatically after each commit, so you only need to do + the full import once per worktree diff --git a/templates/agents/code-search-explorer.md b/templates/agents/code-search-explorer.md index 2a44679..7df372b 100644 --- a/templates/agents/code-search-explorer.md +++ b/templates/agents/code-search-explorer.md @@ -20,11 +20,11 @@ You are an expert Elixir/Erlang codebase explorer powered by the `code_search` C When asked to explore a codebase: 1. **Identify the query type**: - - Finding definitions → Use `code_search location` or `code_search function` - - Understanding calls → Use `code_search calls-from` or `code_search calls-to` - - Tracing paths → Use `code_search trace` or `code_search reverse-trace` - - Module analysis → Use `code_search browse-module` or `code_search depends-on` - - Quality checks → Use `code_search unused`, `code_search hotspots`, etc. + - Finding definitions → Use `code_search code location` or `code_search code function` + - Understanding calls → Use `code_search code calls-from` or `code_search code calls-to` + - Tracing paths → Use `code_search code trace` or `code_search code reverse-trace` + - Module analysis → Use `code_search code browse-module` or `code_search code depends-on` + - Quality checks → Use `code_search code unused`, `code_search code hotspots`, etc. 2. **Execute queries efficiently**: - Always use `--format toon` for token-efficient output @@ -52,7 +52,7 @@ The database is automatically searched in: Override if needed: ```bash -code_search --db /path/to/db.rocksdb +code_search --db /path/to/db.rocksdb code ``` ## Example Workflow @@ -61,17 +61,17 @@ When user asks: "Where is the authenticate function defined and what calls it?" 1. Find definition: ```bash -code_search --format toon location authenticate +code_search --format toon code location authenticate ``` 2. Find callers: ```bash -code_search --format toon calls-to --function authenticate +code_search --format toon code calls-to --function authenticate ``` 3. If results show a specific module, explore it: ```bash -code_search --format toon browse-module AuthModule +code_search --format toon code browse-module AuthModule ``` 4. Read source for context: @@ -83,17 +83,17 @@ code_search --format toon browse-module AuthModule | Task | Command | |------|---------| -| Find function | `code_search --format toon location ` | -| Browse module | `code_search --format toon browse-module ` | -| What calls X? | `code_search --format toon calls-to --function ` | -| What does X call? | `code_search --format toon calls-from ` | -| Trace execution | `code_search --format toon trace --depth N` | -| Find path A→B | `code_search --format toon path --from-module A --to-module B` | -| Module deps | `code_search --format toon depends-on ` | -| Who depends on X? | `code_search --format toon depended-by ` | -| Unused code | `code_search --format toon unused` | -| Hotspots | `code_search --format toon hotspots --kind incoming` | -| Code smells | `code_search --format toon god-modules`, `complexity`, etc. | +| Find function | `code_search --format toon code location ` | +| Browse module | `code_search --format toon code browse-module ` | +| What calls X? | `code_search --format toon code calls-to --function ` | +| What does X call? | `code_search --format toon code calls-from ` | +| Trace execution | `code_search --format toon code trace --depth N` | +| Find path A→B | `code_search --format toon code path --from-module A --to-module B` | +| Module deps | `code_search --format toon code depends-on ` | +| Who depends on X? | `code_search --format toon code depended-by ` | +| Unused code | `code_search --format toon code unused` | +| Hotspots | `code_search --format toon code hotspots --kind incoming` | +| Code smells | `code_search --format toon code god-modules`, `complexity`, etc. | ## Important Notes diff --git a/templates/hooks/post-commit b/templates/hooks/post-commit index c9d471a..17abbc9 100644 --- a/templates/hooks/post-commit +++ b/templates/hooks/post-commit @@ -6,7 +6,7 @@ # from the last commit. It: # 1. Ensures the project is compiled with debug info # 2. Extracts AST data for changed files using ex_ast --git-diff -# 3. Imports the data into the database using code_search import +# 3. Imports the data into the database using code_search code import # # Installation: # cp hooks/post-commit .git/hooks/post-commit @@ -105,7 +105,7 @@ fi # Database path will be auto-resolved to .code_search/surrealdb.rocksdb info "Importing data..." -if code_search import --file "${TEMP_JSON}" 2>&1; then +if code_search code import --file "${TEMP_JSON}" 2>&1; then info "Database updated successfully!" else error "Database import failed" diff --git a/templates/skills/accepts/SKILL.md b/templates/skills/accepts/SKILL.md index 2eef4ca..7a16a08 100644 --- a/templates/skills/accepts/SKILL.md +++ b/templates/skills/accepts/SKILL.md @@ -14,7 +14,7 @@ Find functions that take certain types as input parameters. Use this to understa ## Usage ```bash -code_search --format toon accepts [MODULE] [OPTIONS] +code_search --format toon code accepts [MODULE] [OPTIONS] ``` ## Arguments @@ -34,10 +34,10 @@ code_search --format toon accepts [MODULE] [OPTIONS] ## Examples ```bash -code_search accepts "User.t" # Find functions accepting User.t -code_search accepts "map()" # Find functions accepting maps -code_search accepts "User.t" MyApp # Filter to module MyApp -code_search accepts -r "list\(.*\)" # Regex pattern matching +code_search code accepts "User.t" # Find functions accepting User.t +code_search code accepts "map()" # Find functions accepting maps +code_search code accepts "User.t" MyApp # Filter to module MyApp +code_search code accepts -r "list\(.*\)" # Regex pattern matching ``` ## Output Fields (toon format) diff --git a/templates/skills/boundaries/SKILL.md b/templates/skills/boundaries/SKILL.md index d241643..900e9e3 100644 --- a/templates/skills/boundaries/SKILL.md +++ b/templates/skills/boundaries/SKILL.md @@ -14,7 +14,7 @@ Identify modules that act as architectural boundaries - modules that are heavily ## Usage ```bash -code_search --format toon boundaries [MODULE] [OPTIONS] +code_search --format toon code boundaries [MODULE] [OPTIONS] ``` ## Arguments @@ -35,11 +35,11 @@ code_search --format toon boundaries [MODULE] [OPTIONS] ## Examples ```bash -code_search boundaries # Find all boundary modules -code_search boundaries MyApp.Web # Filter to MyApp.Web namespace -code_search boundaries --min-incoming 5 # With minimum 5 incoming calls -code_search boundaries --min-ratio 2.0 # With minimum 2.0 ratio -code_search boundaries -l 20 # Show top 20 boundary modules +code_search code boundaries # Find all boundary modules +code_search code boundaries MyApp.Web # Filter to MyApp.Web namespace +code_search code boundaries --min-incoming 5 # With minimum 5 incoming calls +code_search code boundaries --min-ratio 2.0 # With minimum 2.0 ratio +code_search code boundaries -l 20 # Show top 20 boundary modules ``` ## Output Fields (toon format) diff --git a/templates/skills/browse-module/SKILL.md b/templates/skills/browse-module/SKILL.md index 94f3297..0a7ba9c 100644 --- a/templates/skills/browse-module/SKILL.md +++ b/templates/skills/browse-module/SKILL.md @@ -14,7 +14,7 @@ Get a complete overview of all functions, specs, types, and structs in a specifi ## Usage ```bash -code_search --format toon browse-module [OPTIONS] +code_search --format toon code browse-module [OPTIONS] ``` ## Arguments diff --git a/templates/skills/calls-from/skill.md b/templates/skills/calls-from/skill.md index 84aa705..83c5c66 100644 --- a/templates/skills/calls-from/skill.md +++ b/templates/skills/calls-from/skill.md @@ -8,7 +8,7 @@ description: Show what a module/function calls (outgoing edges). Use to understa ## All Calls from a Module ```bash -code_search --format toon calls-from Phoenix.Endpoint.RenderErrors +code_search --format toon code calls-from Phoenix.Endpoint.RenderErrors ``` Output: @@ -24,13 +24,13 @@ calls[22]{call_type,callee_arity,callee_function,callee_module,caller_function,c ## Calls from a Specific Function ```bash -code_search --format toon calls-from Phoenix.Controller render +code_search --format toon code calls-from Phoenix.Controller render ``` ## With Specific Arity ```bash -code_search --format toon calls-from Phoenix.Controller render 3 +code_search --format toon code calls-from Phoenix.Controller render 3 ``` ## Understanding Call Types @@ -41,7 +41,7 @@ code_search --format toon calls-from Phoenix.Controller render 3 ## Tracing Error Handling Flow ```bash -code_search --format toon calls-from Phoenix.Endpoint.RenderErrors "__catch__" +code_search --format toon code calls-from Phoenix.Endpoint.RenderErrors "__catch__" ``` This shows what happens when an error is caught - the error handling chain. diff --git a/templates/skills/calls-to/skill.md b/templates/skills/calls-to/skill.md index 3af24e8..a36d65f 100644 --- a/templates/skills/calls-to/skill.md +++ b/templates/skills/calls-to/skill.md @@ -8,7 +8,7 @@ description: Show what calls a module/function (incoming edges). Use to find cal ## Find All Callers of a Function ```bash -code_search --format toon calls-to Mix.Phoenix copy_from +code_search --format toon code calls-to Mix.Phoenix copy_from ``` Output: @@ -23,19 +23,19 @@ calls[14]{call_type,callee_arity,callee_function,callee_module,caller_function,c ## Find All Callers of a Module ```bash -code_search --format toon calls-to Phoenix.Controller +code_search --format toon code calls-to Phoenix.Controller ``` ## Find Callers with Specific Arity ```bash -code_search --format toon calls-to Phoenix.Controller render 3 +code_search --format toon code calls-to Phoenix.Controller render 3 ``` ## Find Internal Recursive Calls ```bash -code_search --format toon calls-to Phoenix.Channel reply +code_search --format toon code calls-to Phoenix.Channel reply ``` Output shows `Phoenix.Channel.reply/2` calling itself (clause delegation): diff --git a/templates/skills/clusters/SKILL.md b/templates/skills/clusters/SKILL.md index 7da595a..2c14bb3 100644 --- a/templates/skills/clusters/SKILL.md +++ b/templates/skills/clusters/SKILL.md @@ -14,7 +14,7 @@ Group modules by their namespace/prefix to understand how different parts of the ## Usage ```bash -code_search --format toon clusters [MODULE] [OPTIONS] +code_search --format toon code clusters [MODULE] [OPTIONS] ``` ## Arguments @@ -35,11 +35,11 @@ code_search --format toon clusters [MODULE] [OPTIONS] ## Examples ```bash -code_search clusters # Show all namespace clusters -code_search clusters MyApp.Core # Filter to MyApp.Core namespace -code_search clusters --depth 2 # Cluster at depth 2 (e.g., MyApp.Accounts) -code_search clusters --depth 3 # Cluster at depth 3 (e.g., MyApp.Accounts.Auth) -code_search clusters --show-dependencies # Include cross-namespace call counts +code_search code clusters # Show all namespace clusters +code_search code clusters MyApp.Core # Filter to MyApp.Core namespace +code_search code clusters --depth 2 # Cluster at depth 2 (e.g., MyApp.Accounts) +code_search code clusters --depth 3 # Cluster at depth 3 (e.g., MyApp.Accounts.Auth) +code_search code clusters --show-dependencies # Include cross-namespace call counts ``` ## Output Fields (toon format) diff --git a/templates/skills/code-search-explorer/SKILL.md b/templates/skills/code-search-explorer/SKILL.md index 87f7cf4..abf1106 100644 --- a/templates/skills/code-search-explorer/SKILL.md +++ b/templates/skills/code-search-explorer/SKILL.md @@ -35,12 +35,12 @@ The codebase must have a call graph extracted and imported: 2. **Import into database**: ```bash code_search setup - code_search import --file call_graph.json + code_search code import --file call_graph.json ``` 3. **Verify setup**: ```bash - code_search search "" # Should return modules if data is imported + code_search code search "" # Should return modules if data is imported ``` ## Quick Examples @@ -51,7 +51,7 @@ The codebase must have a call graph extracted and imported: Where is the process_payment function defined? ``` -**What happens**: Agent runs `code_search --format toon location process_payment` and shows you the file path and line number. +**What happens**: Agent runs `code_search --format toon code location process_payment` and shows you the file path and line number. ### Understanding Call Relationships @@ -59,7 +59,7 @@ Where is the process_payment function defined? What functions call create_user? ``` -**What happens**: Agent runs `code_search --format toon calls-to --function create_user` and lists all callers with locations. +**What happens**: Agent runs `code_search --format toon code calls-to --function create_user` and lists all callers with locations. ### Tracing Execution Flow @@ -67,7 +67,7 @@ What functions call create_user? Trace the execution path from handle_request in ApiController ``` -**What happens**: Agent runs `code_search --format toon trace ApiController handle_request --depth 3` showing the full call tree. +**What happens**: Agent runs `code_search --format toon code trace ApiController handle_request --depth 3` showing the full call tree. ### Module Analysis @@ -75,7 +75,7 @@ Trace the execution path from handle_request in ApiController Show me everything in the Authentication module ``` -**What happens**: Agent runs `code_search --format toon browse-module Authentication` listing all public functions, types, and specs. +**What happens**: Agent runs `code_search --format toon code browse-module Authentication` listing all public functions, types, and specs. ### Dependency Analysis @@ -83,7 +83,7 @@ Show me everything in the Authentication module What modules does PaymentGateway depend on? ``` -**What happens**: Agent runs `code_search --format toon depends-on PaymentGateway` showing direct and transitive dependencies. +**What happens**: Agent runs `code_search --format toon code depends-on PaymentGateway` showing direct and transitive dependencies. ### Finding Dead Code @@ -91,7 +91,7 @@ What modules does PaymentGateway depend on? Find unused functions in this codebase ``` -**What happens**: Agent runs `code_search --format toon unused` listing functions with zero callers. +**What happens**: Agent runs `code_search --format toon code unused` listing functions with zero callers. ### Code Quality Checks @@ -167,17 +167,17 @@ The agent uses `--format toon` for token efficiency, but you can also run comman - **Table** (default): Human-readable output ```bash - code_search location authenticate + code_search code location authenticate ``` - **JSON**: For scripts/tools ```bash - code_search --format json location authenticate + code_search --format json code location authenticate ``` - **Toon**: Token-efficient for LLMs (what the agent uses) ```bash - code_search --format toon location authenticate + code_search --format toon code location authenticate ``` ## Database Configuration @@ -189,7 +189,7 @@ Database is automatically searched in this order: Override with `--db` flag if needed: ```bash -code_search --db /path/to/db.rocksdb +code_search --db /path/to/db.rocksdb code ``` ## Tips for Best Results @@ -215,17 +215,17 @@ You can also run `code_search` directly: ```bash # Get help code_search --help -code_search --help +code_search code --help # Common queries -code_search location my_function -code_search browse-module MyApp.Module -code_search calls-to --function process -code_search trace MyModule process --depth 2 -code_search depends-on MyApp.Core -code_search unused -code_search hotspots --kind incoming --limit 20 -code_search god-modules +code_search code location my_function +code_search code browse-module MyApp.Module +code_search code calls-to --function process +code_search code trace MyModule process --depth 2 +code_search code depends-on MyApp.Core +code_search code unused +code_search code hotspots --kind incoming --limit 20 +code_search code god-modules ``` ## Related Resources @@ -242,9 +242,9 @@ code_search god-modules **Question**: "How does authentication work in this app?" **Agent workflow**: -1. `code_search --format toon search auth` → Find auth-related modules -2. `code_search --format toon browse-module AuthController` → See public interface -3. `code_search --format toon trace AuthController login` → Follow login flow +1. `code_search --format toon code search auth` → Find auth-related modules +2. `code_search --format toon code browse-module AuthController` → See public interface +3. `code_search --format toon code trace AuthController login` → Follow login flow 4. Read relevant source files for implementation details 5. Summarize the authentication flow @@ -253,8 +253,8 @@ code_search god-modules **Question**: "Can I safely delete the User.send_notification function?" **Agent workflow**: -1. `code_search --format toon calls-to --function send_notification` → Find callers -2. `code_search --format toon reverse-trace User send_notification` → Full reverse tree +1. `code_search --format toon code calls-to --function send_notification` → Find callers +2. `code_search --format toon code reverse-trace User send_notification` → Full reverse tree 3. Report: "This function is called from 3 places: OrderController, AlertService, and AdminPanel" 4. User can decide based on impact @@ -263,8 +263,8 @@ code_search god-modules **Question**: "What code can I delete from the Reports module?" **Agent workflow**: -1. `code_search --format toon unused --module Reports` → Find unused functions -2. `code_search --format toon browse-module Reports` → Show all functions +1. `code_search --format toon code unused --module Reports` → Find unused functions +2. `code_search --format toon code browse-module Reports` → Show all functions 3. Compare and identify private functions with zero callers 4. Report candidates for deletion with file paths @@ -274,7 +274,7 @@ code_search god-modules - **Solution**: Run `code_search setup` first (creates `.code_search/surrealdb.rocksdb`) **Issue**: "No results found" -- **Solution**: Check if data is imported with `code_search search ""` +- **Solution**: Check if data is imported with `code_search code search ""` - **Solution**: Try broader search terms or remove filters **Issue**: "Too many results" diff --git a/templates/skills/code-search-explorer/reference.md b/templates/skills/code-search-explorer/reference.md index 27fab60..adc907c 100644 --- a/templates/skills/code-search-explorer/reference.md +++ b/templates/skills/code-search-explorer/reference.md @@ -4,46 +4,46 @@ ### Discovery & Search ```bash -code_search search # Find modules/functions by name -code_search browse-module # Show module contents -code_search location # Find where function is defined -code_search function # Get function details +code_search code search # Find modules/functions by name +code_search code browse-module # Show module contents +code_search code location # Find where function is defined +code_search code function # Get function details ``` ### Call Graph Navigation ```bash -code_search calls-from # What does X call? -code_search calls-to --function # What calls X? -code_search trace --depth N # Forward call tree -code_search reverse-trace # Backward call tree -code_search path --from-module A --to-module B # Find call path A→B +code_search code calls-from # What does X call? +code_search code calls-to --function # What calls X? +code_search code trace --depth N # Forward call tree +code_search code reverse-trace # Backward call tree +code_search code path --from-module A --to-module B # Find call path A→B ``` ### Module Dependencies ```bash -code_search depends-on # What does module depend on? -code_search depended-by # What depends on module? -code_search clusters # Find module clusters -code_search cycles # Find circular dependencies -code_search boundaries # Identify architectural boundaries +code_search code depends-on # What does module depend on? +code_search code depended-by # What depends on module? +code_search code clusters # Find module clusters +code_search code cycles # Find circular dependencies +code_search code boundaries # Identify architectural boundaries ``` ### Code Quality ```bash -code_search unused # Find unused functions -code_search hotspots --kind # Find coupling hotspots -code_search god-modules # Find overly large modules -code_search complexity # Find complex functions -code_search large-functions # Find long functions -code_search many-clauses # Functions with many clauses -code_search duplicates # Find duplicate signatures +code_search code unused # Find unused functions +code_search code hotspots --kind # Find coupling hotspots +code_search code god-modules # Find overly large modules +code_search code complexity # Find complex functions +code_search code large-functions # Find long functions +code_search code many-clauses # Functions with many clauses +code_search code duplicates # Find duplicate signatures ``` ### Type Analysis ```bash -code_search accepts # Functions accepting a type -code_search returns # Functions returning a type -code_search struct-usage # Where is struct used? +code_search code accepts # Functions accepting a type +code_search code returns # Functions returning a type +code_search code struct-usage # Where is struct used? ``` ## Global Flags @@ -74,19 +74,19 @@ code_search struct-usage # Where is struct used? ### Table (Human-readable) ```bash -code_search location authenticate +code_search code location authenticate # Shows: module, function, file, line in a table ``` ### JSON (Programmatic) ```bash -code_search --format json location authenticate +code_search --format json code location authenticate # Returns structured JSON ``` ### Toon (Token-efficient for LLMs) ```bash -code_search --format toon location authenticate +code_search --format toon code location authenticate # Returns compact format: # results[1]: # module: MyApp.Auth @@ -100,42 +100,42 @@ code_search --format toon location authenticate ### Find and Explore a Function ```bash # 1. Find it -code_search location authenticate +code_search code location authenticate # 2. See what it calls -code_search calls-from MyApp.Auth authenticate +code_search code calls-from MyApp.Auth authenticate # 3. See what calls it -code_search calls-to --function authenticate +code_search code calls-to --function authenticate # 4. Trace its execution -code_search trace MyApp.Auth authenticate --depth 2 +code_search code trace MyApp.Auth authenticate --depth 2 ``` ### Module Impact Analysis ```bash # 1. What does it contain? -code_search browse-module MyApp.Payment +code_search code browse-module MyApp.Payment # 2. What does it depend on? -code_search depends-on MyApp.Payment +code_search code depends-on MyApp.Payment # 3. What depends on it? -code_search depended-by MyApp.Payment +code_search code depended-by MyApp.Payment # 4. Any circular deps? -code_search cycles +code_search code cycles ``` ### Code Quality Audit ```bash # Find all quality issues -code_search unused -code_search god-modules -code_search complexity --limit 20 -code_search large-functions --limit 10 -code_search cycles -code_search hotspots --kind total --limit 15 +code_search code unused +code_search code god-modules +code_search code complexity --limit 20 +code_search code large-functions --limit 10 +code_search code cycles +code_search code hotspots --kind total --limit 15 ``` ## Tips @@ -152,12 +152,12 @@ code_search hotspots --kind total --limit 15 code_search setup # Import call graph data (from ex_ast) -code_search import --file call_graph.json +code_search code import --file call_graph.json ``` ## Need More Help? ```bash code_search --help # General help -code_search --help # Command-specific help +code_search code --help # Command-specific help ``` diff --git a/templates/skills/complexity/SKILL.md b/templates/skills/complexity/SKILL.md index 3bc5b62..dc27d3d 100644 --- a/templates/skills/complexity/SKILL.md +++ b/templates/skills/complexity/SKILL.md @@ -14,7 +14,7 @@ Analyze function complexity to identify potentially problematic or hard-to-maint ## Usage ```bash -code_search --format toon complexity [MODULE] [OPTIONS] +code_search --format toon code complexity [MODULE] [OPTIONS] ``` ## Arguments @@ -36,12 +36,12 @@ code_search --format toon complexity [MODULE] [OPTIONS] ## Examples ```bash -code_search complexity # Show all functions with complexity >= 1 -code_search complexity MyApp.Accounts # Filter to MyApp.Accounts module -code_search complexity --min 10 # Show functions with complexity >= 10 -code_search complexity --min-depth 3 # Show functions with nesting depth >= 3 -code_search complexity --exclude-generated # Exclude macro-generated functions -code_search complexity -l 20 # Show top 20 most complex functions +code_search code complexity # Show all functions with complexity >= 1 +code_search code complexity MyApp.Accounts # Filter to MyApp.Accounts module +code_search code complexity --min 10 # Show functions with complexity >= 10 +code_search code complexity --min-depth 3 # Show functions with nesting depth >= 3 +code_search code complexity --exclude-generated # Exclude macro-generated functions +code_search code complexity -l 20 # Show top 20 most complex functions ``` ## Output Fields (toon format) diff --git a/templates/skills/cycles/SKILL.md b/templates/skills/cycles/SKILL.md index fd7fd18..849a6ba 100644 --- a/templates/skills/cycles/SKILL.md +++ b/templates/skills/cycles/SKILL.md @@ -14,7 +14,7 @@ Find circular dependencies in the module graph that can cause compilation issues ## Usage ```bash -code_search --format toon cycles [MODULE] [OPTIONS] +code_search --format toon code cycles [MODULE] [OPTIONS] ``` ## Arguments @@ -35,10 +35,10 @@ code_search --format toon cycles [MODULE] [OPTIONS] ## Examples ```bash -code_search cycles # Find all cycles -code_search cycles MyApp.Core # Filter to MyApp.Core namespace -code_search cycles --max-length 3 # Only show cycles of length <= 3 -code_search cycles --involving MyApp.Accounts # Only cycles involving Accounts +code_search code cycles # Find all cycles +code_search code cycles MyApp.Core # Filter to MyApp.Core namespace +code_search code cycles --max-length 3 # Only show cycles of length <= 3 +code_search code cycles --involving MyApp.Accounts # Only cycles involving Accounts ``` ## Output Fields (toon format) diff --git a/templates/skills/depended-by/skill.md b/templates/skills/depended-by/skill.md index 5e903a0..17a23dd 100644 --- a/templates/skills/depended-by/skill.md +++ b/templates/skills/depended-by/skill.md @@ -3,7 +3,7 @@ ## Find Dependents of a Module ```bash -code_search --format toon depended-by Phoenix.Controller +code_search --format toon code depended-by Phoenix.Controller ``` Output: @@ -17,7 +17,7 @@ dependents[3]{call_count,module,project}: ## Find Dependents with Regex ```bash -code_search --format toon depended-by 'Ecto\..*' --regex +code_search --format toon code depended-by 'Ecto\..*' --regex ``` ## Understanding the Output @@ -29,7 +29,7 @@ code_search --format toon depended-by 'Ecto\..*' --regex Before changing `Phoenix.Controller`: ```bash -code_search --format toon depended-by Phoenix.Controller +code_search --format toon code depended-by Phoenix.Controller ``` Shows 3 modules with 17 total calls would be affected. @@ -38,7 +38,7 @@ Shows 3 modules with 17 total calls would be affected. Modules with many dependents are core infrastructure: ```bash -code_search --format toon depended-by MyApp.Repo +code_search --format toon code depended-by MyApp.Repo ``` If many modules depend on Repo, it's a central piece of the architecture. diff --git a/templates/skills/depends-on/skill.md b/templates/skills/depends-on/skill.md index 948f71e..736813e 100644 --- a/templates/skills/depends-on/skill.md +++ b/templates/skills/depends-on/skill.md @@ -3,7 +3,7 @@ ## Find Module Dependencies ```bash -code_search --format toon depends-on Phoenix.Channel +code_search --format toon code depends-on Phoenix.Channel ``` Output: @@ -15,7 +15,7 @@ dependencies[1]{call_count,module,project}: ## Find Dependencies of Multiple Modules ```bash -code_search --format toon depends-on 'Phoenix\.Controller.*' --regex +code_search --format toon code depends-on 'Phoenix\.Controller.*' --regex ``` ## Understanding the Output @@ -29,7 +29,7 @@ Higher call counts indicate stronger coupling. Check what a core module depends on: ```bash -code_search --format toon depends-on MyApp.Accounts +code_search --format toon code depends-on MyApp.Accounts ``` This reveals: diff --git a/templates/skills/duplicates/SKILL.md b/templates/skills/duplicates/SKILL.md index ae2d9f6..ff812e0 100644 --- a/templates/skills/duplicates/SKILL.md +++ b/templates/skills/duplicates/SKILL.md @@ -14,7 +14,7 @@ Identify code duplication to find opportunities for refactoring and consolidatio ## Usage ```bash -code_search --format toon duplicates [MODULE] [OPTIONS] +code_search --format toon code duplicates [MODULE] [OPTIONS] ``` ## Arguments @@ -36,11 +36,11 @@ code_search --format toon duplicates [MODULE] [OPTIONS] ## Examples ```bash -code_search duplicates # Find all duplicate functions -code_search duplicates MyApp # Filter to specific module -code_search duplicates --by-module # Rank modules by duplication -code_search duplicates --exact # Use exact source matching -code_search duplicates --exclude-generated # Exclude macro-generated functions +code_search code duplicates # Find all duplicate functions +code_search code duplicates MyApp # Filter to specific module +code_search code duplicates --by-module # Rank modules by duplication +code_search code duplicates --exact # Use exact source matching +code_search code duplicates --exclude-generated # Exclude macro-generated functions ``` ## Output Fields (toon format) diff --git a/templates/skills/function/skill.md b/templates/skills/function/skill.md index 0fe31c8..873f444 100644 --- a/templates/skills/function/skill.md +++ b/templates/skills/function/skill.md @@ -3,7 +3,7 @@ ## Get Function Signature ```bash -code_search --format toon function Phoenix.Controller render +code_search --format toon code function Phoenix.Controller render ``` Output: @@ -16,7 +16,7 @@ functions[2]{args,arity,module,name,project,return_type}: ## Filter by Arity ```bash -code_search --format toon function Phoenix.Controller render --arity 2 +code_search --format toon code function Phoenix.Controller render --arity 2 ``` Output: @@ -28,7 +28,7 @@ functions[1]{args,arity,module,name,project,return_type}: ## Regex Search for Multiple Functions ```bash -code_search --format toon function Phoenix.Controller 'put_.*' --regex +code_search --format toon code function Phoenix.Controller 'put_.*' --regex ``` ## Understanding the Output diff --git a/templates/skills/god-modules/SKILL.md b/templates/skills/god-modules/SKILL.md index 294ee3a..7b8990b 100644 --- a/templates/skills/god-modules/SKILL.md +++ b/templates/skills/god-modules/SKILL.md @@ -14,7 +14,7 @@ Identify modules that violate single responsibility principle by having too many ## Usage ```bash -code_search --format toon god-modules [MODULE] [OPTIONS] +code_search --format toon code god-modules [MODULE] [OPTIONS] ``` ## Arguments @@ -36,12 +36,12 @@ code_search --format toon god-modules [MODULE] [OPTIONS] ## Examples ```bash -code_search god-modules # Find all god modules -code_search god-modules MyApp.Core # Filter to MyApp.Core namespace -code_search god-modules --min-functions 30 # With minimum 30 functions -code_search god-modules --min-loc 500 # With minimum 500 lines of code -code_search god-modules --min-total 15 # With minimum 15 total connectivity -code_search god-modules -l 20 # Show top 20 god modules +code_search code god-modules # Find all god modules +code_search code god-modules MyApp.Core # Filter to MyApp.Core namespace +code_search code god-modules --min-functions 30 # With minimum 30 functions +code_search code god-modules --min-loc 500 # With minimum 500 lines of code +code_search code god-modules --min-total 15 # With minimum 15 total connectivity +code_search code god-modules -l 20 # Show top 20 god modules ``` ## Output Fields (toon format) diff --git a/templates/skills/hotspots/skill.md b/templates/skills/hotspots/skill.md index 8e5d5ce..396f625 100644 --- a/templates/skills/hotspots/skill.md +++ b/templates/skills/hotspots/skill.md @@ -3,7 +3,7 @@ ## Find Most Called Functions ```bash -code_search --format toon hotspots +code_search --format toon code hotspots ``` Output: @@ -20,7 +20,7 @@ hotspots[20]{function,incoming,module,outgoing,total}: ## Find Functions with High Fan-Out ```bash -code_search --format toon hotspots --kind outgoing +code_search --format toon code hotspots --kind outgoing ``` Functions that call many other functions - potential god functions to refactor. @@ -28,13 +28,13 @@ Functions that call many other functions - potential god functions to refactor. ## Find Total Connections ```bash -code_search --format toon hotspots --kind total +code_search --format toon code hotspots --kind total ``` ## Find Boundary Functions ```bash -code_search --format toon hotspots --kind ratio +code_search --format toon code hotspots --kind ratio ``` Functions with high incoming/outgoing ratio - these are API boundaries. @@ -42,7 +42,7 @@ Functions with high incoming/outgoing ratio - these are API boundaries. ## Filter to Specific Module Namespace ```bash -code_search --format toon hotspots Phoenix.Router +code_search --format toon code hotspots Phoenix.Router ``` ## Understanding the Output @@ -55,22 +55,22 @@ code_search --format toon hotspots Phoenix.Router **Find Core Utilities:** ```bash -code_search --format toon hotspots --kind incoming -l 10 +code_search --format toon code hotspots --kind incoming -l 10 ``` **Find Complex Functions (high fan-out):** ```bash -code_search --format toon hotspots --kind outgoing -l 10 +code_search --format toon code hotspots --kind outgoing -l 10 ``` **Find Coupling Hotspots:** ```bash -code_search --format toon hotspots --kind total -l 10 +code_search --format toon code hotspots --kind total -l 10 ``` **Find Boundary Functions:** ```bash -code_search --format toon hotspots --kind ratio -l 10 +code_search --format toon code hotspots --kind ratio -l 10 ``` ## Options Reference diff --git a/templates/skills/import/skill.md b/templates/skills/import/skill.md index 8343679..f52fe2a 100644 --- a/templates/skills/import/skill.md +++ b/templates/skills/import/skill.md @@ -3,7 +3,7 @@ ## Basic Import ```bash -code_search --format toon import --file extracted_trace.json +code_search --format toon code import --file extracted_trace.json ``` Output: @@ -23,13 +23,13 @@ types_imported: 27 Replace all existing data: ```bash -code_search --format toon import --file call_graph.json --clear +code_search --format toon code import --file call_graph.json --clear ``` ## Import to Specific Database ```bash -code_search --db /path/to/my.db --format toon import --file call_graph.json +code_search --db /path/to/my.db --format toon code import --file call_graph.json ``` ## Expected JSON Structure diff --git a/templates/skills/large-functions/SKILL.md b/templates/skills/large-functions/SKILL.md index e6f6860..afd5711 100644 --- a/templates/skills/large-functions/SKILL.md +++ b/templates/skills/large-functions/SKILL.md @@ -14,7 +14,7 @@ Identify functions that are too long or complex based on line count. Use this to ## Usage ```bash -code_search --format toon large-functions [MODULE] [OPTIONS] +code_search --format toon code large-functions [MODULE] [OPTIONS] ``` ## Arguments @@ -35,11 +35,11 @@ code_search --format toon large-functions [MODULE] [OPTIONS] ## Examples ```bash -code_search large-functions # Find functions with 50+ lines -code_search large-functions MyApp.Web # Filter to MyApp.Web namespace -code_search large-functions --min-lines 100 # Find functions with 100+ lines -code_search large-functions --include-generated # Include macro-generated functions -code_search large-functions -l 20 # Show top 20 largest functions +code_search code large-functions # Find functions with 50+ lines +code_search code large-functions MyApp.Web # Filter to MyApp.Web namespace +code_search code large-functions --min-lines 100 # Find functions with 100+ lines +code_search code large-functions --include-generated # Include macro-generated functions +code_search code large-functions -l 20 # Show top 20 largest functions ``` ## Output Fields (toon format) diff --git a/templates/skills/location/skill.md b/templates/skills/location/skill.md index b59f7fc..76d5e45 100644 --- a/templates/skills/location/skill.md +++ b/templates/skills/location/skill.md @@ -3,7 +3,7 @@ ## Find All Definitions of a Function ```bash -code_search --format toon location render +code_search --format toon code location render ``` Output: @@ -18,7 +18,7 @@ locations[15]{arity,end_line,file,guard,kind,module,name,pattern,project,start_l ## Find in Specific Module ```bash -code_search --format toon location reply Phoenix.Channel +code_search --format toon code location reply Phoenix.Channel ``` Output: @@ -31,13 +31,13 @@ locations[2]{arity,end_line,file,guard,kind,module,name,pattern,project,start_li ## Find with Specific Arity ```bash -code_search --format toon location render Phoenix.Controller --arity 3 +code_search --format toon code location render Phoenix.Controller --arity 3 ``` ## Regex Pattern for Multiple Functions ```bash -code_search --format toon location 'handle_.*' --regex --limit 20 +code_search --format toon code location 'handle_.*' --regex --limit 20 ``` ## Understanding the Output diff --git a/templates/skills/many-clauses/SKILL.md b/templates/skills/many-clauses/SKILL.md index aefdfd3..1b9254c 100644 --- a/templates/skills/many-clauses/SKILL.md +++ b/templates/skills/many-clauses/SKILL.md @@ -14,7 +14,7 @@ Identify functions with many pattern matching clauses that may be complex or har ## Usage ```bash -code_search --format toon many-clauses [MODULE] [OPTIONS] +code_search --format toon code many-clauses [MODULE] [OPTIONS] ``` ## Arguments @@ -35,11 +35,11 @@ code_search --format toon many-clauses [MODULE] [OPTIONS] ## Examples ```bash -code_search many-clauses # Find functions with 5+ clauses -code_search many-clauses MyApp.Web # Filter to MyApp.Web namespace -code_search many-clauses --min-clauses 10 # Find functions with 10+ clauses -code_search many-clauses --include-generated # Include macro-generated functions -code_search many-clauses -l 20 # Show top 20 functions with most clauses +code_search code many-clauses # Find functions with 5+ clauses +code_search code many-clauses MyApp.Web # Filter to MyApp.Web namespace +code_search code many-clauses --min-clauses 10 # Find functions with 10+ clauses +code_search code many-clauses --include-generated # Include macro-generated functions +code_search code many-clauses -l 20 # Show top 20 functions with most clauses ``` ## Output Fields (toon format) diff --git a/templates/skills/path/skill.md b/templates/skills/path/skill.md index 3d5971b..f2032b1 100644 --- a/templates/skills/path/skill.md +++ b/templates/skills/path/skill.md @@ -3,7 +3,7 @@ ## Find Path Between Two Functions ```bash -code_search --format toon path \ +code_search --format toon code path \ --from-module MyApp.Web.UserController \ --from-function create \ --to-module Ecto.Repo \ @@ -25,7 +25,7 @@ to_module: Ecto.Repo ## No Path Found ```bash -code_search --format toon path \ +code_search --format toon code path \ --from-module Phoenix.Channel \ --from-function join \ --to-module Mix.Tasks.Compile \ @@ -43,7 +43,7 @@ Empty results means no path exists within the search depth. ## With Specific Arities ```bash -code_search --format toon path \ +code_search --format toon code path \ --from-module MyApp.API --from-function handle --from-arity 2 \ --to-module MyApp.Repo --to-function get --to-arity 2 \ --depth 15 diff --git a/templates/skills/returns/SKILL.md b/templates/skills/returns/SKILL.md index 3725c4e..989e3ab 100644 --- a/templates/skills/returns/SKILL.md +++ b/templates/skills/returns/SKILL.md @@ -14,7 +14,7 @@ Find functions that return values of certain types. Use this to understand what ## Usage ```bash -code_search --format toon returns [MODULE] [OPTIONS] +code_search --format toon code returns [MODULE] [OPTIONS] ``` ## Arguments @@ -34,10 +34,10 @@ code_search --format toon returns [MODULE] [OPTIONS] ## Examples ```bash -code_search returns "User.t" # Find functions returning User.t -code_search returns "nil" # Find functions returning nil -code_search returns "{:error" MyApp # Filter to module MyApp -code_search returns -r "list\(.*\)" # Regex pattern matching +code_search code returns "User.t" # Find functions returning User.t +code_search code returns "nil" # Find functions returning nil +code_search code returns "{:error" MyApp # Filter to module MyApp +code_search code returns -r "list\(.*\)" # Regex pattern matching ``` ## Output Fields (toon format) diff --git a/templates/skills/reverse-trace/skill.md b/templates/skills/reverse-trace/skill.md index d3c5eaa..73005f7 100644 --- a/templates/skills/reverse-trace/skill.md +++ b/templates/skills/reverse-trace/skill.md @@ -3,7 +3,7 @@ ## Find All Paths to a Function ```bash -code_search --format toon reverse-trace Phoenix.Controller render --depth 3 +code_search --format toon code reverse-trace Phoenix.Controller render --depth 3 ``` Output: @@ -22,7 +22,7 @@ calls[18]{callee_arity,callee_function,callee_module,caller_function,caller_kind ## Deeper Trace ```bash -code_search --format toon reverse-trace Ecto.Repo insert --depth 10 +code_search --format toon code reverse-trace Ecto.Repo insert --depth 10 ``` ## Understanding the Output @@ -37,7 +37,7 @@ This reveals the call chain: `__catch__ → instrument_render_and_send → rende ## Use Case: Finding Entry Points ```bash -code_search --format toon reverse-trace MyApp.Repo get --depth 8 +code_search --format toon code reverse-trace MyApp.Repo get --depth 8 ``` Traces backward to find all controller actions or API endpoints that eventually call `Repo.get`. diff --git a/templates/skills/search/skill.md b/templates/skills/search/skill.md index 96b1ce5..8159da8 100644 --- a/templates/skills/search/skill.md +++ b/templates/skills/search/skill.md @@ -3,7 +3,7 @@ ## Find Modules by Name ```bash -code_search --format toon search Phoenix +code_search --format toon code search Phoenix ``` Output: @@ -20,7 +20,7 @@ modules[69]{name,source}: ## Find Functions by Pattern ```bash -code_search --format toon search render --kind functions +code_search --format toon code search render --kind functions ``` Output: @@ -34,7 +34,7 @@ functions[12]{arity,module,name,return_type}: ## Regex Search for Module Prefix ```bash -code_search --format toon search '^Phoenix\.Channel' --regex +code_search --format toon code search '^Phoenix\.Channel' --regex ``` Output: @@ -48,7 +48,7 @@ modules[3]{name,source}: ## Search with Limit ```bash -code_search --format toon search Controller --limit 5 +code_search --format toon code search Controller --limit 5 ``` ## Options Reference diff --git a/templates/skills/struct-usage/SKILL.md b/templates/skills/struct-usage/SKILL.md index b8ab9bc..56d421d 100644 --- a/templates/skills/struct-usage/SKILL.md +++ b/templates/skills/struct-usage/SKILL.md @@ -14,7 +14,7 @@ Find all functions that work with a specific struct type, either as input parame ## Usage ```bash -code_search --format toon struct-usage [MODULE] [OPTIONS] +code_search --format toon code struct-usage [MODULE] [OPTIONS] ``` ## Arguments @@ -35,11 +35,11 @@ code_search --format toon struct-usage [MODULE] [OPTIONS] ## Examples ```bash -code_search struct-usage "User.t" # Find functions using User.t -code_search struct-usage "Changeset.t" # Find functions using Changeset.t -code_search struct-usage "User.t" MyApp # Filter to module MyApp -code_search struct-usage "User.t" --by-module # Summarize by module -code_search struct-usage -r ".*\.t" # Regex pattern matching +code_search code struct-usage "User.t" # Find functions using User.t +code_search code struct-usage "Changeset.t" # Find functions using Changeset.t +code_search code struct-usage "User.t" MyApp # Filter to module MyApp +code_search code struct-usage "User.t" --by-module # Summarize by module +code_search code struct-usage -r ".*\.t" # Regex pattern matching ``` ## Output Fields (toon format) diff --git a/templates/skills/trace/skill.md b/templates/skills/trace/skill.md index b4a950a..a34bb80 100644 --- a/templates/skills/trace/skill.md +++ b/templates/skills/trace/skill.md @@ -3,7 +3,7 @@ ## Basic Forward Trace ```bash -code_search --format toon trace Phoenix.Endpoint.RenderErrors "__catch__" --depth 3 +code_search --format toon code trace Phoenix.Endpoint.RenderErrors "__catch__" --depth 3 ``` Output: @@ -18,13 +18,13 @@ calls[N]{callee_arity,callee_function,callee_module,caller_function,caller_kind, ## Deeper Traversal ```bash -code_search --format toon trace MyApp.Web index --depth 10 +code_search --format toon code trace MyApp.Web index --depth 10 ``` ## Trace with Arity Filter ```bash -code_search --format toon trace Phoenix.Controller render --arity 2 --depth 3 +code_search --format toon code trace Phoenix.Controller render --arity 2 --depth 3 ``` ## Understanding Depth @@ -38,7 +38,7 @@ Each level shows what gets called at that depth in the call chain. ## Use Case: Understanding Error Handling ```bash -code_search --format toon trace Phoenix.Endpoint.RenderErrors "__catch__" --depth 5 +code_search --format toon code trace Phoenix.Endpoint.RenderErrors "__catch__" --depth 5 ``` This reveals the full error handling pipeline: catch → instrument → render → controller. diff --git a/templates/skills/unused/skill.md b/templates/skills/unused/skill.md index 1b25a44..98af9b9 100644 --- a/templates/skills/unused/skill.md +++ b/templates/skills/unused/skill.md @@ -3,7 +3,7 @@ ## Find All Unused Functions ```bash -code_search --format toon unused +code_search --format toon code unused ``` Output: @@ -19,7 +19,7 @@ functions[10]{arity,file,kind,line,module,name,project}: ## Find Unused Public Functions ```bash -code_search --format toon unused -P +code_search --format toon code unused -P ``` These are potential entry points or dead API surface. @@ -27,7 +27,7 @@ These are potential entry points or dead API surface. ## Find Orphan Private Functions ```bash -code_search --format toon unused -p +code_search --format toon code unused -p ``` Private functions that are never called are definitely dead code. @@ -35,7 +35,7 @@ Private functions that are never called are definitely dead code. ## Exclude Generated Functions ```bash -code_search --format toon unused -Px +code_search --format toon code unused -Px ``` Filters out `__struct__`, `__using__`, `__before_compile__`, etc. @@ -43,7 +43,7 @@ Filters out `__struct__`, `__using__`, `__before_compile__`, etc. ## Filter to Specific Module ```bash -code_search --format toon unused MyApp.Accounts +code_search --format toon code unused MyApp.Accounts ``` ## Understanding Results diff --git a/templates/skills/workflows/code-quality-audit.md b/templates/skills/workflows/code-quality-audit.md index 2841f84..8774af9 100644 --- a/templates/skills/workflows/code-quality-audit.md +++ b/templates/skills/workflows/code-quality-audit.md @@ -26,13 +26,13 @@ Systematically assess codebase health by identifying architectural issues, compl Cycles create maintenance nightmares: ```bash # Find all circular dependencies -code_search --format toon cycles +code_search --format toon code cycles # Limit to shorter cycles (more problematic) -code_search --format toon cycles --max-length 3 +code_search --format toon code cycles --max-length 3 # Check if a specific module is involved in cycles -code_search --format toon cycles --involving MyApp.Core +code_search --format toon code cycles --involving MyApp.Core ``` **Red flags**: Any cycles, especially short ones (2-3 modules). @@ -42,13 +42,13 @@ code_search --format toon cycles --involving MyApp.Core Modules doing too much: ```bash # Find modules with many functions and high connectivity -code_search --format toon god-modules +code_search --format toon code god-modules # Adjust thresholds for your codebase -code_search --format toon god-modules --min-functions 30 --min-total 20 +code_search --format toon code god-modules --min-functions 30 --min-total 20 # Filter to specific namespace -code_search --format toon god-modules MyApp.Core +code_search --format toon code god-modules MyApp.Core ``` **Red flags**: Modules with 50+ functions or 30+ total connections. @@ -58,16 +58,16 @@ code_search --format toon god-modules MyApp.Core Functions that are hard to understand: ```bash # Find functions with high complexity scores -code_search --format toon complexity --min 10 +code_search --format toon code complexity --min 10 # Find deeply nested functions -code_search --format toon complexity --min-depth 4 +code_search --format toon code complexity --min-depth 4 # Find large functions by line count -code_search --format toon large-functions --min-lines 50 +code_search --format toon code large-functions --min-lines 50 # Find functions with many pattern-match clauses -code_search --format toon many-clauses --min-clauses 8 +code_search --format toon code many-clauses --min-clauses 8 ``` **Red flags**: Complexity > 15, nesting > 4, lines > 100, clauses > 10. @@ -77,13 +77,13 @@ code_search --format toon many-clauses --min-clauses 8 Find over-connected code: ```bash # Most called functions (might be over-used) -code_search --format toon hotspots --kind incoming -l 20 +code_search --format toon code hotspots --kind incoming -l 20 # Functions that call too many things (god functions) -code_search --format toon hotspots --kind outgoing -l 20 +code_search --format toon code hotspots --kind outgoing -l 20 # Total connectivity hotspots -code_search --format toon hotspots --kind total -l 20 +code_search --format toon code hotspots --kind total -l 20 ``` **Red flags**: Functions with > 20 incoming or > 10 outgoing calls. @@ -93,14 +93,14 @@ code_search --format toon hotspots --kind total -l 20 Verify layer separation: ```bash # Find boundary modules (high fan-in, low fan-out) -code_search --format toon boundaries +code_search --format toon code boundaries # Analyze module clusters -code_search --format toon clusters --show-dependencies +code_search --format toon code clusters --show-dependencies # Check a specific module's position -code_search --format toon depends-on MyApp.Web.UserController -code_search --format toon depended-by MyApp.Web.UserController +code_search --format toon code depends-on MyApp.Web.UserController +code_search --format toon code depended-by MyApp.Web.UserController ``` **Red flags**: Controllers depending on many modules, data layer with high fan-out. @@ -110,16 +110,16 @@ code_search --format toon depended-by MyApp.Web.UserController Code that can be removed: ```bash # Unused functions -code_search --format toon unused -x +code_search --format toon code unused -x # Focus on definitely-dead private functions -code_search --format toon unused -px +code_search --format toon code unused -px # Find duplicated code -code_search --format toon duplicates +code_search --format toon code duplicates # Modules with most duplication -code_search --format toon duplicates --by-module +code_search --format toon code duplicates --by-module ``` **Red flags**: > 5% unused functions, significant duplication. @@ -131,31 +131,31 @@ Run all checks and compile results: ```bash # 1. Cycles echo "=== CIRCULAR DEPENDENCIES ===" -code_search --format toon cycles --max-length 4 +code_search --format toon code cycles --max-length 4 # 2. God Modules echo "=== GOD MODULES ===" -code_search --format toon god-modules -l 10 +code_search --format toon code god-modules -l 10 # 3. Complexity echo "=== COMPLEX FUNCTIONS ===" -code_search --format toon complexity --min 10 -l 10 +code_search --format toon code complexity --min 10 -l 10 # 4. Large Functions echo "=== LARGE FUNCTIONS ===" -code_search --format toon large-functions --min-lines 75 -l 10 +code_search --format toon code large-functions --min-lines 75 -l 10 # 5. Coupling Hotspots echo "=== COUPLING HOTSPOTS ===" -code_search --format toon hotspots --kind total -l 10 +code_search --format toon code hotspots --kind total -l 10 # 6. Unused Code echo "=== UNUSED CODE ===" -code_search --format toon unused -px -l 20 +code_search --format toon code unused -px -l 20 # 7. Duplicates echo "=== DUPLICATES ===" -code_search --format toon duplicates -l 10 +code_search --format toon code duplicates -l 10 ``` ## Interpreting Results diff --git a/templates/skills/workflows/find-dead-code.md b/templates/skills/workflows/find-dead-code.md index a281225..e8f4d45 100644 --- a/templates/skills/workflows/find-dead-code.md +++ b/templates/skills/workflows/find-dead-code.md @@ -25,13 +25,13 @@ Identify and safely remove unused code to reduce maintenance burden and improve Private functions that are never called are guaranteed dead: ```bash # Find all unused private functions -code_search --format toon unused -p +code_search --format toon code unused -p # Exclude compiler-generated functions -code_search --format toon unused -px +code_search --format toon code unused -px # Filter to specific area -code_search --format toon unused -p MyApp.Legacy +code_search --format toon code unused -p MyApp.Legacy ``` **These are safe to delete** - private functions can only be called from within their module. @@ -41,10 +41,10 @@ code_search --format toon unused -p MyApp.Legacy Public functions might be called from external code: ```bash # Find unused public functions -code_search --format toon unused -P +code_search --format toon code unused -P # Exclude generated functions (__struct__, __info__, etc.) -code_search --format toon unused -Px +code_search --format toon code unused -Px ``` **Before deleting**, verify: @@ -58,7 +58,7 @@ code_search --format toon unused -Px Modules with no incoming dependencies might be dead: ```bash # For each suspicious module, check dependents -code_search --format toon depended-by MyApp.OldFeature +code_search --format toon code depended-by MyApp.OldFeature # If result shows 0 dependents and not a known entry point, likely dead ``` @@ -75,10 +75,10 @@ Common false positives: Code that's duplicated might indicate dead or consolidatable functions: ```bash # Find duplicate implementations -code_search --format toon duplicates +code_search --format toon code duplicates # See which modules have most duplication -code_search --format toon duplicates --by-module +code_search --format toon code duplicates --by-module ``` ### 5. Validate Before Deleting @@ -86,10 +86,10 @@ code_search --format toon duplicates --by-module For each candidate: ```bash # Double-check no callers -code_search --format toon calls-to ModuleName function_name +code_search --format toon code calls-to ModuleName function_name # Check if it's a boundary/entry point -code_search --format toon hotspots ModuleName +code_search --format toon code hotspots ModuleName # Functions with 0 incoming but called from outside Elixir won't show here ``` @@ -97,25 +97,25 @@ code_search --format toon hotspots ModuleName ```bash # 1. Find all unused functions in legacy area -code_search --format toon unused MyApp.Legacy +code_search --format toon code unused MyApp.Legacy # Result shows 12 unused functions: # - 8 private (defp) - safe to delete # - 4 public (def) - need verification # 2. Check the private functions -code_search --format toon unused -p MyApp.Legacy +code_search --format toon code unused -p MyApp.Legacy # Confirmed: 8 private functions never called # 3. For each public function, verify -code_search --format toon calls-to MyApp.Legacy old_helper +code_search --format toon code calls-to MyApp.Legacy old_helper # 0 callers - can delete -code_search --format toon calls-to MyApp.Legacy format_data +code_search --format toon code calls-to MyApp.Legacy format_data # 0 internal callers, but check if it's API # 4. Check if the whole module is orphaned -code_search --format toon depended-by MyApp.Legacy +code_search --format toon code depended-by MyApp.Legacy # 0 dependents - entire module might be deletable # 5. Safe to remove: diff --git a/templates/skills/workflows/impact-analysis.md b/templates/skills/workflows/impact-analysis.md index d7d8b5b..236b6ce 100644 --- a/templates/skills/workflows/impact-analysis.md +++ b/templates/skills/workflows/impact-analysis.md @@ -24,10 +24,10 @@ Be specific about the change: Start with immediate impact: ```bash # Who calls this function directly? -code_search --format toon calls-to MyApp.Payments charge +code_search --format toon code calls-to MyApp.Payments charge # For a specific arity -code_search --format toon calls-to MyApp.Payments charge 2 +code_search --format toon code calls-to MyApp.Payments charge 2 ``` ### 3. Find Transitive Callers @@ -35,10 +35,10 @@ code_search --format toon calls-to MyApp.Payments charge 2 Changes propagate up the call chain: ```bash # Trace backwards to find all paths to this function -code_search --format toon reverse-trace MyApp.Payments charge --depth 5 +code_search --format toon code reverse-trace MyApp.Payments charge --depth 5 # Increase depth for widely-used functions -code_search --format toon reverse-trace MyApp.Repo insert --depth 10 +code_search --format toon code reverse-trace MyApp.Repo insert --depth 10 ``` ### 4. Check Module-Level Impact @@ -46,10 +46,10 @@ code_search --format toon reverse-trace MyApp.Repo insert --depth 10 For broader changes, check module dependencies: ```bash # What modules depend on this one? -code_search --format toon depended-by MyApp.Payments +code_search --format toon code depended-by MyApp.Payments # Check if any of those are also widely used -code_search --format toon depended-by MyApp.PaymentsWeb +code_search --format toon code depended-by MyApp.PaymentsWeb ``` ### 5. Assess Type-Level Impact @@ -57,13 +57,13 @@ code_search --format toon depended-by MyApp.PaymentsWeb If changing types or structs: ```bash # Who uses this type? -code_search --format toon struct-usage Payment.t +code_search --format toon code struct-usage Payment.t # Who accepts this type? -code_search --format toon accepts Payment.t +code_search --format toon code accepts Payment.t # Who returns this type? -code_search --format toon returns Payment.t +code_search --format toon code returns Payment.t ``` ### 6. Check for Boundary Crossings @@ -71,10 +71,10 @@ code_search --format toon returns Payment.t See if the change affects architectural boundaries: ```bash # Is this a boundary module (many callers, few dependencies)? -code_search --format toon boundaries MyApp.Payments +code_search --format toon code boundaries MyApp.Payments # Check cluster membership -code_search --format toon clusters MyApp.Payments +code_search --format toon code clusters MyApp.Payments ``` Changes to boundary modules have wider impact. @@ -84,15 +84,15 @@ Changes to boundary modules have wider impact. Get concrete numbers: ```bash # Count callers -code_search --format toon calls-to MyApp.Payments charge +code_search --format toon code calls-to MyApp.Payments charge # Look at the count in output # Count dependent modules -code_search --format toon depended-by MyApp.Payments +code_search --format toon code depended-by MyApp.Payments # Look at the count in output # Check hotspot status -code_search --format toon hotspots MyApp.Payments +code_search --format toon code hotspots MyApp.Payments # High incoming = high impact ``` @@ -102,19 +102,19 @@ You want to change `MyApp.Accounts.get_user/1` to `get_user/2` (adding options): ```bash # 1. Find direct callers -code_search --format toon calls-to MyApp.Accounts get_user +code_search --format toon code calls-to MyApp.Accounts get_user # Result: 15 direct callers # 2. Trace backwards -code_search --format toon reverse-trace MyApp.Accounts get_user --depth 4 +code_search --format toon code reverse-trace MyApp.Accounts get_user --depth 4 # Result: Shows call chains from controllers, jobs, other contexts # 3. Check module impact -code_search --format toon depended-by MyApp.Accounts +code_search --format toon code depended-by MyApp.Accounts # Result: 8 modules depend on Accounts # 4. See if it's a hotspot -code_search --format toon hotspots MyApp.Accounts +code_search --format toon code hotspots MyApp.Accounts # Result: get_user has 15 incoming calls - medium impact # Conclusion: Need to update 15 call sites across 8 modules @@ -126,18 +126,18 @@ You want to remove `MyApp.LegacyPayments`: ```bash # 1. Check if anything depends on it -code_search --format toon depended-by MyApp.LegacyPayments +code_search --format toon code depended-by MyApp.LegacyPayments # Result: 0 dependents - safe to delete! # Or if there are dependents: # Result: 3 modules still depend on it # 2. Find specific usages -code_search --format toon calls-to MyApp.LegacyPayments +code_search --format toon code calls-to MyApp.LegacyPayments # Shows exactly which functions are still called # 3. Check for type usage -code_search --format toon struct-usage LegacyPayment.t +code_search --format toon code struct-usage LegacyPayment.t # Shows if the struct is still used anywhere ``` diff --git a/templates/skills/workflows/trace-execution-flow.md b/templates/skills/workflows/trace-execution-flow.md index eac84e1..7052387 100644 --- a/templates/skills/workflows/trace-execution-flow.md +++ b/templates/skills/workflows/trace-execution-flow.md @@ -22,13 +22,13 @@ Entry points are typically: Find potential entry points: ```bash # Find controller actions -code_search --format toon search Controller --kind modules +code_search --format toon code search Controller --kind modules # Browse a controller to find actions -code_search --format toon browse-module MyApp.UserController +code_search --format toon code browse-module MyApp.UserController # Find GenServer callbacks -code_search --format toon location handle_call +code_search --format toon code location handle_call ``` ### 2. Trace Forward from Entry Point @@ -36,10 +36,10 @@ code_search --format toon location handle_call Use `trace` to follow the call chain: ```bash # Trace 5 levels deep (default) -code_search --format toon trace MyApp.UserController create +code_search --format toon code trace MyApp.UserController create # Trace deeper for complex flows -code_search --format toon trace MyApp.UserController create --depth 10 +code_search --format toon code trace MyApp.UserController create --depth 10 ``` **Reading the output:** @@ -52,17 +52,17 @@ code_search --format toon trace MyApp.UserController create --depth 10 When you see an interesting callee, dive deeper: ```bash # What does this specific function call? -code_search --format toon calls-from MyApp.Accounts create_user +code_search --format toon code calls-from MyApp.Accounts create_user # Continue tracing from there -code_search --format toon trace MyApp.Accounts create_user --depth 5 +code_search --format toon code trace MyApp.Accounts create_user --depth 5 ``` ### 4. Find the Path Between Two Points If you know the start and end: ```bash -code_search --format toon path \ +code_search --format toon code path \ --from-module MyApp.UserController --from-function create \ --to-module MyApp.Repo --to-function insert ``` @@ -74,23 +74,23 @@ This shows exactly how the controller action reaches the database. Sometimes it's useful to trace backwards: ```bash # Who calls this low-level function? -code_search --format toon reverse-trace MyApp.Repo insert --depth 3 +code_search --format toon code reverse-trace MyApp.Repo insert --depth 3 # Find all callers (single level) -code_search --format toon calls-to MyApp.Repo insert +code_search --format toon code calls-to MyApp.Repo insert ``` ## Example: Tracing a User Registration Flow ```bash # 1. Find the registration controller -code_search --format toon search Registration +code_search --format toon code search Registration # 2. Browse the controller -code_search --format toon browse-module MyApp.RegistrationController +code_search --format toon code browse-module MyApp.RegistrationController # 3. Trace from the create action -code_search --format toon trace MyApp.RegistrationController create --depth 8 +code_search --format toon code trace MyApp.RegistrationController create --depth 8 # 4. Output reveals the flow: # Controller.create diff --git a/templates/skills/workflows/understand-feature.md b/templates/skills/workflows/understand-feature.md index 6167992..67be6f7 100644 --- a/templates/skills/workflows/understand-feature.md +++ b/templates/skills/workflows/understand-feature.md @@ -16,12 +16,12 @@ Build a complete mental model of a feature by exploring it vertically through al Start by searching for related modules: ```bash # Search by feature name -code_search --format toon search Payment -code_search --format toon search Billing -code_search --format toon search Subscription +code_search --format toon code search Payment +code_search --format toon code search Billing +code_search --format toon code search Subscription # Search with regex for related patterns -code_search --format toon search '^MyApp\.Payments' --regex +code_search --format toon code search '^MyApp\.Payments' --regex ``` ### 2. Identify the Core Module @@ -29,12 +29,12 @@ code_search --format toon search '^MyApp\.Payments' --regex Usually there's a central module that orchestrates the feature: ```bash # Browse candidate modules -code_search --format toon browse-module MyApp.Payments -code_search --format toon browse-module MyApp.Billing +code_search --format toon code browse-module MyApp.Payments +code_search --format toon code browse-module MyApp.Billing # Check which one has more connections (likely the core) -code_search --format toon depended-by MyApp.Payments -code_search --format toon depended-by MyApp.Billing +code_search --format toon code depended-by MyApp.Payments +code_search --format toon code depended-by MyApp.Billing ``` The module with more dependents is often the public API of the feature. @@ -44,13 +44,13 @@ The module with more dependents is often the public API of the feature. Understand what the core module provides: ```bash # See all public functions -code_search --format toon browse-module MyApp.Payments --kind functions +code_search --format toon code browse-module MyApp.Payments --kind functions # See type definitions -code_search --format toon browse-module MyApp.Payments --kind types +code_search --format toon code browse-module MyApp.Payments --kind types # See struct definitions -code_search --format toon browse-module MyApp.Payments --kind structs +code_search --format toon code browse-module MyApp.Payments --kind structs ``` ### 4. Explore Upward (Who Uses This Feature?) @@ -58,13 +58,13 @@ code_search --format toon browse-module MyApp.Payments --kind structs Find the entry points and consumers: ```bash # What modules depend on this feature? -code_search --format toon depended-by MyApp.Payments +code_search --format toon code depended-by MyApp.Payments # Find specific callers of key functions -code_search --format toon calls-to MyApp.Payments process_payment +code_search --format toon code calls-to MyApp.Payments process_payment # Trace backwards to find entry points -code_search --format toon reverse-trace MyApp.Payments process_payment --depth 5 +code_search --format toon code reverse-trace MyApp.Payments process_payment --depth 5 ``` This reveals: @@ -77,10 +77,10 @@ This reveals: Find the dependencies: ```bash # What does this module depend on? -code_search --format toon depends-on MyApp.Payments +code_search --format toon code depends-on MyApp.Payments # Trace forward from key functions -code_search --format toon trace MyApp.Payments process_payment --depth 5 +code_search --format toon code trace MyApp.Payments process_payment --depth 5 ``` This reveals: @@ -93,11 +93,11 @@ This reveals: Understand what data types flow through the feature: ```bash # What functions accept the main struct? -code_search --format toon struct-usage Payment.t +code_search --format toon code struct-usage Payment.t # Or search by type pattern -code_search --format toon accepts Payment -code_search --format toon returns Payment +code_search --format toon code accepts Payment +code_search --format toon code returns Payment ``` ### 7. Check for Related Background Processing @@ -105,40 +105,40 @@ code_search --format toon returns Payment Features often have async components: ```bash # Find related workers/jobs -code_search --format toon search PaymentWorker -code_search --format toon search 'Payment.*Job' --regex +code_search --format toon code search PaymentWorker +code_search --format toon code search 'Payment.*Job' --regex # Find GenServer patterns -code_search --format toon search PaymentServer +code_search --format toon code search PaymentServer ``` ## Example: Understanding the Authentication Feature ```bash # 1. Find auth-related modules -code_search --format toon search Auth +code_search --format toon code search Auth # Found: MyApp.Auth, MyApp.Auth.Guardian, MyApp.Auth.Pipeline # 2. Browse the main module -code_search --format toon browse-module MyApp.Auth +code_search --format toon code browse-module MyApp.Auth # Shows: authenticate/2, register/1, verify_token/1, etc. # 3. Who uses auth? -code_search --format toon depended-by MyApp.Auth +code_search --format toon code depended-by MyApp.Auth # Found: SessionController, ApiController, all protected controllers # 4. What does auth depend on? -code_search --format toon depends-on MyApp.Auth +code_search --format toon code depends-on MyApp.Auth # Found: Repo, Guardian, Comeonin # 5. Trace a key flow -code_search --format toon trace MyApp.Auth authenticate --depth 5 +code_search --format toon code trace MyApp.Auth authenticate --depth 5 # Shows: authenticate → verify_password → Comeonin.check_pass # → load_user → Repo.get_by # → create_token → Guardian.encode_and_sign # 6. Map the user data flow -code_search --format toon struct-usage User.t MyApp.Auth +code_search --format toon code struct-usage User.t MyApp.Auth ``` ## Building the Mental Model