Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,59 @@ sia-code config set search.vector_weight 0.0

Note: backend selection is auto by default (`sqlite-vec` for new indexes, legacy `usearch` supported).

## Multi-Worktree / Multi-Agent Setup

Yes - Sia Code works with multiple git worktrees and multiple LLM CLI instances.

Scope resolution order:

1. `SIA_CODE_INDEX_DIR` (explicit path override)
2. `SIA_CODE_INDEX_SCOPE` (`shared`, `worktree`, or `auto`)
3. `auto` fallback:
- linked worktree -> shared index at `<git-common-dir>/sia-code`
- normal checkout -> local `.sia-code`

```bash
# Shared index across worktrees/agents
export SIA_CODE_INDEX_SCOPE=shared

# Isolated index per worktree
export SIA_CODE_INDEX_SCOPE=worktree

# Full explicit control
export SIA_CODE_INDEX_DIR=/absolute/path/to/sia-index
```

Typical worktree workflow:

```bash
# in main checkout (build shared index once)
export SIA_CODE_INDEX_SCOPE=shared
sia-code init
sia-code index .

# create feature worktree
git worktree add ../feat-auth feat/auth

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add branch-creation flag to worktree example

The workflow command git worktree add ../feat-auth feat/auth will fail for users who are creating a new feature branch, because feat/auth is treated as an existing <commit-ish> unless -b/-B is provided. git worktree add -h documents this as git worktree add ... [(-b | -B) <new-branch>] <path> [<commit-ish>] and explicitly says -b <branch> create a new branch, so the current example is not copy-paste safe in the common “new branch” scenario.

Useful? React with 👍 / 👎.

cd ../feat-auth

# reuse same shared index, then incrementally refresh
sia-code status
sia-code index --update
```

When a worktree is merged/removed:

- `shared` scope: index stays in git common dir and remains usable
- `worktree` scope: index lives in that worktree directory and is removed with it
- after merge, run `sia-code index --update` in the remaining checkout

Practical guidance:

- Many readers/searchers are fine in shared mode
- Prefer one active index writer per shared index
- For strict branch/agent isolation, use `worktree`
- Teams on different machines should keep local indexes and sync context via git + `sia-code memory sync-git`

## Documentation

- `docs/CLI_FEATURES.md` - concise CLI command reference
Expand Down
19 changes: 19 additions & 0 deletions docs/INDEXING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ sia-code index .
| Parallel | `sia-code index --parallel --workers 8` | Large repos |
| Watch | `sia-code index --watch --debounce 2.0` | Continuous local development |

## Worktrees and Multiple Agent Sessions

Sia Code supports git worktrees and parallel LLM CLI sessions.

- Auto behavior in linked worktrees: shared index at `<git-common-dir>/sia-code`
- Override behavior with env vars:

```bash
export SIA_CODE_INDEX_SCOPE=shared # share one index across worktrees
export SIA_CODE_INDEX_SCOPE=worktree # per-worktree .sia-code
export SIA_CODE_INDEX_DIR=/absolute/path/to/sia-index
```

Practical guidance:

- Many concurrent readers/searchers are fine
- For indexing, prefer one writer at a time on the same shared index
- If you need hard isolation per agent, use `SIA_CODE_INDEX_SCOPE=worktree`

## What gets indexed

- Code files for supported languages
Expand Down
24 changes: 24 additions & 0 deletions docs/LLM_CLI_INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ uvx sia-code memory search "topic"
uvx sia-code memory add-decision "Decision title" -d "Context" -r "Reason"
```

## 5) Multiple worktrees / multiple Claude Code instances

Use one of these index strategies per session:

```bash
# Shared index across worktrees/instances (best for reuse)
export SIA_CODE_INDEX_SCOPE=shared

# Isolated index per worktree/instance
export SIA_CODE_INDEX_SCOPE=worktree
```

If you need full control, set an explicit directory:

```bash
export SIA_CODE_INDEX_DIR=/absolute/path/to/sia-index
```

Recommendation:

- Shared mode for many search/read sessions
- Worktree mode when you want strict isolation per branch/agent
- For shared mode, avoid many simultaneous index writers

## Notes

- Keep the skill file short and practical for agent speed.
Expand Down
Loading