Initialize Serena for a repository session and ensure project context is ready
At the start of any session in a repository.
.git directory exists. If not:
git init to initialize the repositoryempty_folder=trueNote: After initial code is created, re-running /bootstrap will:
.serena/project.yml configuration| Command | Action when empty folder detected |
|---|---|
/bootstrap | Report empty status, suggest workflow, STOP |
/brainstorm | Continue — exploration works without existing code |
/architect | Continue — architecture design works without existing code |
/plan-change, /apply-change | Continue — creating new code is valid |
/code-review, /validate | STOP — requires existing code to review |
serena-context-sync tool to ensure the opencode context is deployed to ~/.serena/contexts/opencode.ymlopencode context (single-project mode via --project-from-cwd). Do NOT call activate_project — it is not available in this context.check_onboarding_performedonboardingget_current_configlist_memoriesIdentify the project domain early — it determines which Serena tools are useful and which validation commands apply:
| Domain | Key indicators | Serena value |
|---|---|---|
| Code (Go/Python/TS) | go.mod, pyproject.toml, package.json, *.go, *.py, *.ts | Full: navigation, symbolic editing, memory |
| Kubernetes | apiVersion: + kind: in YAML, deploy/, manifests/ | Limited: memory, search_for_pattern |
| Helm | Chart.yaml, values.yaml, templates/ | Limited: memory, search_for_pattern |
| Kustomize | kustomization.yaml | Limited: memory, search_for_pattern |
| Ansible | playbook*.yml, roles/, ansible.cfg | Limited: memory, search_for_pattern |
| Mixed | Multiple domains present | Use domain of files being changed |
For infra-only projects, Serena is still useful for memory (storing validation commands, chart conventions, manifest structure) and search_for_pattern (cross-file text search), but symbolic editing tools will not apply.
Load only the memory categories relevant to the current task:
| Task type | Memory categories to load |
|---|---|
| Code changes (plan/apply) | build-and-test/, architecture-invariants/, recurring-pitfalls/ |
| Infra changes (K8s/Helm/Kustomize/Ansible) | build-and-test/, architecture-invariants/, recurring-pitfalls/ |
| Reviews (platform, obs, ansible, helm, gha) | architecture-invariants/, repo-structure/ |
| Debugging (investigate, fix) | recurring-pitfalls/, build-and-test/ |
| Bootstrap (session start) | repo-structure/, local-dev-notes/ |
| Memory management | (load as needed per task) |
The opencode context excludes file I/O and shell tools from Serena (OpenCode handles those natively). If you see errors about unavailable tools like read_file, write_file, list_directory, or execute_command, this is expected — use OpenCode's built-in tools instead.
Each repository using Serena should have a .serena/project.yml file. If missing during onboarding, Serena creates one automatically. Key settings to verify:
project_name — identifies the project in multi-project setupslanguage_servers — ensure relevant LSPs are configured (Go, Python, TypeScript, YAML/Ansible as needed)read_only_memory_patterns — protect critical memories from accidental edits (recommended: ["architecture-invariants/*"])ignored_memory_patterns — hide archived or deprecated memories from list_memories resultsAfter bootstrap, you can check project status at the Serena dashboard: http://localhost:45411 (default port when Serena MCP is running).