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
14 changes: 7 additions & 7 deletions plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Install the plugin, open a Git repo, and ask Claude about the code:
Claude will use local commands such as:

```bash
git-kb code doctor
git-kb code doctor --json
git-kb code index
git-kb code symbols
git-kb code callers "<symbol>"
git-kb code callees "<symbol>"
git-kb code impact path/to/file
git-kb code dead
git-kb code query
git-kb code symbols --json
git-kb code callers "<symbol>" --json
git-kb code callees "<symbol>" --json
git-kb code impact path/to/file --json
git-kb code dead --json
git-kb code query hotspots --json
```

No `.kb` project is required for those code intelligence commands.
Expand Down
8 changes: 4 additions & 4 deletions plugin/scripts/session-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ NL=$'\n'
CONTEXT=""

if ! command_exists git-kb; then
CONTEXT="# GitKB Setup${NL}${NL}The GitKB CLI is not installed, so GitKB code intelligence is unavailable in this session.${NL}${NL}Install it with:${NL}${NL}\`\`\`bash${NL}brew install gitkb/tap/gitkb${NL}# or${NL}curl -fsSL https://get.gitkb.com/install.sh | bash${NL}\`\`\`${NL}${NL}After installing, use \`git-kb code doctor\`, \`git-kb code index\`, and related \`git-kb code ...\` commands in any Git repo. Full persistent KB setup is optional via \`git-kb init && git-kb init claude\`."
CONTEXT="# GitKB Setup${NL}${NL}The GitKB CLI is not installed, so GitKB code intelligence is unavailable in this session.${NL}${NL}Install it with:${NL}${NL}\`\`\`bash${NL}brew install gitkb/tap/gitkb${NL}# or${NL}curl -fsSL https://get.gitkb.com/install.sh | bash${NL}\`\`\`${NL}${NL}After installing, use \`git-kb code doctor --json\`, \`git-kb code index\`, and related \`git-kb code ... --json\` commands in any Git repo. Full persistent KB setup is optional via \`git-kb init && git-kb init claude\`."
Comment thread
mateodelnorte marked this conversation as resolved.
Resolved
elif GITKB_ROOT="$CWD" git-kb info >/dev/null 2>&1; then
CONTEXT="# GitKB Ready${NL}${NL}This project has a full \`.kb\` setup. For durable tasks, knowledge, sync, or full Claude integration, use the canonical assets installed by \`git-kb init claude\`. If setup appears stale or missing, ask the user before running \`git-kb init claude --dry-run\` or \`git-kb doctor --check repos,code,kb\`."
CONTEXT="# GitKB Ready${NL}${NL}This project has a full \`.kb\` setup. For durable tasks, knowledge, sync, or full Claude integration, use the canonical assets installed by \`git-kb init claude\`. If setup appears stale or missing, ask the user before running \`git-kb init claude --dry-run\` or \`git-kb doctor --check repos,code,kb --json\`."
elif git -C "$CWD" rev-parse --show-toplevel >/dev/null 2>&1; then
CONTEXT="# GitKB Code Intelligence${NL}${NL}This Git repo does not have a full \`.kb\` yet, but GitKB code intelligence works without initialization.${NL}${NL}**Prefer \`git-kb code\` over grep for code exploration.** Grep matches text; \`git-kb code\` understands the AST and call graph.${NL}${NL}For code questions, prefer these local CLI commands:${NL}${NL}- \`git-kb code doctor\` to inspect language/index health.${NL}- \`git-kb code index\` before first analysis or after large changes.${NL}- \`git-kb code symbols\`, \`git-kb code callers\`, \`git-kb code callees\`, \`git-kb code impact\`, \`git-kb code dead\`, and \`git-kb code query\` for code intelligence.${NL}${NL}Do not require \`git-kb init\` for code intelligence. If the user wants durable tasks, knowledge, sync, or full Claude integration, guide them through:${NL}${NL}\`\`\`bash${NL}git-kb init${NL}git-kb init claude${NL}\`\`\`${NL}${NL}MCP is supported after full KB setup today; use CLI fallback when MCP is unavailable."
CONTEXT="# GitKB Code Intelligence${NL}${NL}This Git repo does not have a full \`.kb\` yet, but GitKB code intelligence works without initialization.${NL}${NL}**Prefer \`git-kb code ... --json\` over grep for code exploration.** Grep matches text; \`git-kb code\` understands the AST and call graph, and JSON output preserves complete symbol IDs and stable fields.${NL}${NL}For code questions, prefer these local CLI commands:${NL}${NL}- \`git-kb code doctor --json\` to inspect language/index health.${NL}- \`git-kb code index\` before first analysis or after large changes.${NL}- \`git-kb code symbols --json\`, \`git-kb code callers <symbol> --json\`, \`git-kb code callees <symbol> --json\`, \`git-kb code impact <path> --json\`, \`git-kb code dead --json\`, and \`git-kb code query hotspots --json\` for code intelligence.${NL}${NL}Do not require \`git-kb init\` for code intelligence. If the user wants durable tasks, knowledge, sync, or full Claude integration, guide them through:${NL}${NL}\`\`\`bash${NL}git-kb init${NL}git-kb init claude${NL}\`\`\`${NL}${NL}MCP is supported after full KB setup today; use CLI fallback when MCP is unavailable."
else
CONTEXT="# GitKB Setup${NL}${NL}GitKB is installed, but this directory is not inside a Git repo and does not have a full \`.kb\` project.${NL}${NL}For immediate code intelligence, open a Git repo and run \`git-kb code doctor\` or \`git-kb code index\`. For persistent project memory, initialize GitKB with:${NL}${NL}\`\`\`bash${NL}git-kb init${NL}git-kb init claude${NL}\`\`\`"
CONTEXT="# GitKB Setup${NL}${NL}GitKB is installed, but this directory is not inside a Git repo and does not have a full \`.kb\` project.${NL}${NL}For immediate code intelligence, open a Git repo and run \`git-kb code doctor --json\` or \`git-kb code index\`. For persistent project memory, initialize GitKB with:${NL}${NL}\`\`\`bash${NL}git-kb init${NL}git-kb init claude${NL}\`\`\`"
fi

CONTEXT_JSON=$(json_escape "$CONTEXT")
Expand Down
26 changes: 13 additions & 13 deletions plugin/skills/gitkb/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ When exploring code relationships, prefer `git-kb code` over grep. Grep matches

| Instead of | Use |
|---|---|
| grep for function callers | `git-kb code callers "<symbol>"` |
| grep for definitions | `git-kb code symbols --file <path>` |
| grep to assess change impact | `git-kb code impact <path>` |
| manual dead code search | `git-kb code dead` |
| grep for function callers | `git-kb code callers "<symbol>" --json` |
| grep for definitions | `git-kb code symbols --file <path> --json` |
| grep to assess change impact | `git-kb code impact <path> --json` |
| manual dead code search | `git-kb code dead --json` |

## Code Intelligence Without `.kb`

Expand All @@ -44,18 +44,18 @@ GitKB code intelligence works in a normal Git repo without `git-kb init`.
Use these commands for code questions:

```bash
git-kb code doctor
git-kb code doctor --json
git-kb code index
git-kb code symbols
git-kb code symbols --file path/to/file
git-kb code callers "<symbol>"
git-kb code callees "<symbol>"
git-kb code impact path/to/file
git-kb code dead
git-kb code query
git-kb code symbols --json
git-kb code symbols --file path/to/file --json
git-kb code callers "<symbol>" --json
git-kb code callees "<symbol>" --json
git-kb code impact path/to/file --json
git-kb code dead --json
git-kb code query hotspots --json
```

Run `git-kb code doctor` first when you need to understand index health or language support. Run `git-kb code index` before first analysis or after large code changes.
Run `git-kb code doctor --json` first when you need to understand index health or language support. Run `git-kb code index` before first analysis or after large code changes.

Use GitKB code intelligence before broad refactors, symbol renames, dead-code removal, dependency cleanup, service-edge analysis, or questions about how code flows through the repository.

Expand Down
3 changes: 2 additions & 1 deletion tests/helpers/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ setup_test_kb() {
GITKB_ROOT="$TEST_KB_ROOT" git-kb create \
--type task \
--slug tasks/test-1 \
--title "Test Task" 2>/dev/null
--title "Test Task" \
--json 2>/dev/null

GITKB_ROOT="$TEST_KB_ROOT" git-kb commit -m "test task" tasks/test-1 2>/dev/null

Expand Down
8 changes: 7 additions & 1 deletion tests/session-start.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ teardown() {
ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
[[ "$ctx" == *"GitKB Ready"* ]]
[[ "$ctx" == *"git-kb init claude"* ]]
[[ "$ctx" == *"git-kb doctor --check repos,code,kb --json"* ]]
[[ "$ctx" != *"tasks/test-1"* ]]

local wp
Expand Down Expand Up @@ -102,8 +103,12 @@ teardown() {
ctx=$(echo "$output" | jq -r '.hookSpecificOutput.additionalContext')
[[ "$ctx" == *"GitKB Code Intelligence"* ]]
[[ "$ctx" == *"works without initialization"* ]]
[[ "$ctx" == *"git-kb code doctor"* ]]
[[ "$ctx" == *"git-kb code doctor --json"* ]]
[[ "$ctx" == *"git-kb code index"* ]]
[[ "$ctx" == *"git-kb code symbols --json"* ]]
[[ "$ctx" == *"git-kb code callers <symbol> --json"* ]]
[[ "$ctx" == *"git-kb code query hotspots --json"* ]]
[[ "$ctx" == *"JSON output preserves complete symbol IDs and stable fields"* ]]
[[ "$ctx" == *"Do not require \`git-kb init\` for code intelligence"* ]]
[[ "$ctx" != *"Repository root:"* ]]
[[ "$ctx" != *"$repo"* ]]
Expand Down Expand Up @@ -177,6 +182,7 @@ teardown() {
[[ "$ctx" == *"GitKB CLI is not installed"* ]]
[[ "$ctx" == *"brew install gitkb/tap/gitkb"* ]]
[[ "$ctx" == *"curl -fsSL https://get.gitkb.com/install.sh | bash"* ]]
[[ "$ctx" == *"git-kb code doctor --json"* ]]

rm -rf "$repo" "$tmpbin"
}
Expand Down
Loading