---
name: devxkit-gitnexus-recovery
description: Diagnose and recover GitNexus MCP and pending index refresh without auto-killing processes.
scope: global
devxkit_commands:
  - devxkit gitnexus mcp-status
  - devxkit gitnexus mcp-dedupe
  - devxkit gitnexus refresh-pending
  - devxkit gitnexus analyze
---

# devxkit gitnexus recovery

## When to use

- GitNexus index is STALE, post-commit refresh was skipped, or `.git/gitnexus-refresh-pending` exists
- Duplicate GitNexus MCP clients may be running (Cursor + other IDE)
- Agent needs read-only status before suggesting human recovery
- For MCP tool usage policy, consult the consumer project's GitNexus documentation

## Preconditions

- Run from the indexed repository root
- Prefer read-only commands first; mutating refresh/analyze is **human-initiated** unless user explicitly delegates

## Commands

```bash
devxkit gitnexus mcp-status
devxkit gitnexus mcp-dedupe
devxkit gitnexus refresh-pending
devxkit gitnexus analyze
```

Typical recovery sequence (human):

```bash
devxkit gitnexus mcp-status
# Several MCP clients may legitimately share the registry; CWD is not index ownership
devxkit gitnexus refresh-pending || devxkit gitnexus analyze
devxkit gitnexus status    # structured freshness cross-check
```

## Validation

- `mcp-status` lists zero or known-safe MCP processes before analyze
- After successful refresh: pending marker cleared, index FRESH in status output
- `devxkit gitnexus refresh-pending` exit 0 when recovery completes

## Common failures

- **BUSY** → an exact holder (lsof) or a writer targeting *this* repository was found; `refresh-pending` keeps the marker. Unrelated MCP servers and other indexes do not block
- **UNKNOWN** → inspection incomplete (lsof missing/failed, unverifiable writer); fail closed, inspect manually
- **STALE_LOCK** → a recovery sidecar (`lbug.lock`, `lbug.wal`, …) exists without a holder; quiesce clients and recover by hand. DevXKit never removes it
- **Several MCP clients** → `mcp-dedupe` reports only; it never suggests termination from CWD and agents **never auto-kill**
- **analyze blocked** → wait for lock release; do not delete `.gitnexus/` locks without explicit instruction
- **Node/runtime mismatch** → human runs install/update per `gitnexus/gitnexus-cli`

## Stop conditions

- **Agents:** use `devxkit gitnexus status` / `devxkit gitnexus mcp-status` read-only; do not auto-refresh on STALE
- Do **not** run `analyze` while this index is BUSY, UNKNOWN or STALE_LOCK
- Do **not** delete lock files or kill processes unless the user explicitly authorizes it
- Do **not** run raw `gitnexus analyze` / `npx gitnexus` when policy says `gnx-analyze-here`

## Related skills

- `gitnexus/gitnexus-cli`, `gitnexus/gitnexus-debugging`, `gitnexus/gitnexus-guide`
