$npx -y skills add Dianel555/DSkills --skill serenaSemantic code understanding with IDE-like symbol operations. Use when: (1) Large codebase analysis (>50 files), (2) Symbol-level operations (find, rename, refactor), (3) Cross-file reference tracking, (4) Project memory and session persistence, (5) Multi-language semantic navigat
| 1 | # Serena - Semantic Code Understanding |
| 2 | |
| 3 | IDE-like semantic code operations via CLI. Provides symbol-level code navigation, editing, and project memory. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | ```bash |
| 8 | pip install serena-agent typer pyyaml |
| 9 | ``` |
| 10 | |
| 11 | ## Quick Start |
| 12 | |
| 13 | **First-time setup**: Launch the Web Dashboard to initialize and register the project: |
| 14 | |
| 15 | ```bash |
| 16 | python -m tools dashboard serve --open-browser |
| 17 | ``` |
| 18 | |
| 19 | This will: |
| 20 | - Initialize Serena configuration |
| 21 | - Register the current project in `~/.serena/serena_config.yml` |
| 22 | - Open the Web Dashboard for monitoring and configuration |
| 23 | |
| 24 | **Configuration**: Edit `.env` file in `skills/serena/` directory: |
| 25 | ```bash |
| 26 | SERENA_CONTEXT=claude-code |
| 27 | SERENA_MODES=interactive,editing,onboarding |
| 28 | SERENA_PROJECT=. |
| 29 | ``` |
| 30 | |
| 31 | ## Usage |
| 32 | |
| 33 | ### Basic Command Structure |
| 34 | |
| 35 | ```bash |
| 36 | python -m tools [GLOBAL OPTIONS] <command> [COMMAND OPTIONS] |
| 37 | ``` |
| 38 | |
| 39 | **Global Options** (must be specified before the command): |
| 40 | - `-p, --project PATH` - Project directory (default: current directory, env: SERENA_PROJECT) |
| 41 | - `-c, --context TEXT` - Execution context (auto-detected if not specified, env: SERENA_CONTEXT) |
| 42 | - `-m, --mode TEXT` - Operation modes (can be specified multiple times, env: SERENA_MODES) |
| 43 | |
| 44 | ### Working with Different Projects |
| 45 | |
| 46 | **Important**: When working with projects in different locations (especially cross-drive on Windows), use `--project`: |
| 47 | |
| 48 | ```bash |
| 49 | # Correct: Use --project for different project locations |
| 50 | python -m tools --project "/path/to/project" symbol find MyClass |
| 51 | python -m tools --project "E:\MyProject" file search "pattern" |
| 52 | |
| 53 | # Incorrect: Don't use --path with absolute paths from different drives |
| 54 | python -m tools file search "pattern" --path "E:\MyProject" # Will fail! |
| 55 | ``` |
| 56 | |
| 57 | The `--path` option in subcommands expects **relative paths** within the project. Always use `--project` to set the project root first. |
| 58 | |
| 59 | ### Common Operations |
| 60 | |
| 61 | ```bash |
| 62 | # Dashboard |
| 63 | python -m tools dashboard serve --open-browser |
| 64 | python -m tools dashboard info |
| 65 | |
| 66 | # Symbol operations |
| 67 | python -m tools symbol find MyClass --body |
| 68 | python -m tools symbol overview src/main.py |
| 69 | python -m tools symbol refs MyClass/method |
| 70 | python -m tools symbol rename OldName NewName --path src/file.py |
| 71 | |
| 72 | # Memory operations |
| 73 | python -m tools memory list |
| 74 | python -m tools memory read project_overview |
| 75 | python -m tools memory write api_notes --content "..." |
| 76 | |
| 77 | # File operations |
| 78 | python -m tools file list --recursive |
| 79 | python -m tools file find "**/*.py" |
| 80 | python -m tools file search "TODO:.*" --path src |
| 81 | |
| 82 | # Extended tools |
| 83 | python -m tools cmd run "git status" |
| 84 | python -m tools config read config.json |
| 85 | ``` |
| 86 | |
| 87 | ## Tool Routing Policy |
| 88 | |
| 89 | ### Prefer Serena Over Built-in Tools |
| 90 | |
| 91 | | Task | Avoid | Use Serena CLI | |
| 92 | |------|-------|----------------| |
| 93 | | Find function | `grep "def func"` | `symbol find func --body` | |
| 94 | | List file structure | `cat file.py` | `symbol overview file.py` | |
| 95 | | Find usages | `grep "func("` | `symbol refs func` | |
| 96 | | Edit function | `Edit` tool | `symbol replace func --path file.py` | |
| 97 | | Rename | Manual find/replace | `symbol rename old new --path file.py` | |
| 98 | |
| 99 | ### When to Use Built-in Tools |
| 100 | - Simple text search (non-code patterns) |
| 101 | - Configuration files (JSON, YAML) |
| 102 | - Documentation files (Markdown) |
| 103 | |
| 104 | ## Command Reference |
| 105 | |
| 106 | ### Dashboard Commands |
| 107 | | Command | Description | |
| 108 | |---------|-------------| |
| 109 | | `dashboard serve [--open-browser] [--browser-cmd <path>]` | Start Web Dashboard server | |
| 110 | | `dashboard info` | Show current configuration | |
| 111 | | `dashboard tools` | List active and available tools | |
| 112 | | `dashboard modes` | List active and available modes | |
| 113 | | `dashboard contexts` | List active and available contexts | |
| 114 | |
| 115 | ### Symbol Commands |
| 116 | | Command | Description | |
| 117 | |---------|-------------| |
| 118 | | `symbol find <name> [--body] [--depth N] [--path file]` | Find symbols by name | |
| 119 | | `symbol overview <path>` | List all symbols in file | |
| 120 | | `symbol refs <name> [--path file]` | Find symbol references | |
| 121 | | `symbol replace <name> --path <file> --body <code>` | Replace symbol body | |
| 122 | | `symbol insert-after <name> --path <file> --content <code>` | Insert after symbol | |
| 123 | | `symbol insert-before <name> --path <file> --content <code>` | Insert before symbol | |
| 124 | | `symbol rename <name> <new> --path <file>` | Rename symbol | |
| 125 | |
| 126 | ### Memory Commands |
| 127 | | Command | Description | |
| 128 | |---------|-------------| |
| 129 | | `memory list` | List all memories | |
| 130 | | `memory read <name>` | Read memory content | |
| 131 | | `memory write <name> --content <text>` | Create/update memory | |
| 132 | | `memory edit <name> --content <text>` | Edit memory | |
| 133 | | `memory delete <name>` | Delete memory | |
| 134 | |
| 135 | ### Fil |