agentleFS
valperevalpere/session-indexer/.claude/skills/debug/SKILL.md

debug

Skill42 starsChanged 4 months agoApache-2.0View on GitHub

Systematic bug diagnosis — reproduce, isolate, hypothesize, verify, fix. Usage: /debug [what's broken]

  • Reads credentials
  • Sends data out

192 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use add-discord, add-slack and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    add-discord

    Add Discord bot channel integration via Chat SDK.

    Also in 11 projects that use this

  • MicrosoftSkill

    add-slack

    Add Slack channel integration via Chat SDK.

    Also in 11 projects that use this

  • +10 more from microsoft

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 10 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 175 edited versions we read keep these.

  • 10

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Verify you can reproduce it consistently.

    line 21
  2. Distinctive:

    If you can't reproduce it: Stop. Gather more information.

    line 24
  3. Distinctive:

    Test each boundary — where does correct input produce wrong output?

    line 31
  4. Distinctive:

    Run the test that confirms or refutes.

    line 55
  5. Distinctive:

    Keep a short log: what you tried, what you learned.

    line 58
  6. Distinctive:

    Run the full test suite.

    line 63
  7. Distinctive:

    Add a regression test that would have caught this bug.

    line 64
  8. Distinctive:

    Commit message explains *why*, not just *what*:

    line 65
  9. Distinctive:

    Always add a regression test: If it broke once, it can break again.

    line 108
  10. Distinctive:

    No debug env vars in source yet [project pre-implementation].

    line 142
  11. Very specific:

    Use os.Getenv("SESSION_INDEXER_DEBUG") or similar for verbose output

    line 143
  12. Very specific:

    If Ollama is slow, embedding 100 chunks can hit ~30s.

    line 210

“Common” is measured: kept by at least 6 in 10 of the 175 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: /debug

Systematic Bug Diagnosis


PROTOCOL

Bugs have two parts: the symptom (what you observe) and the cause (what's actually wrong). The protocol moves from symptom → cause → fix, one verified step at a time.

Phase 1 — Reproduce

Goal: Reliable, minimal reproduction before touching any code.

  1. State the symptom precisely: what input, what output, what was expected.
  2. Find the smallest input that triggers it.
  3. Verify you can reproduce it consistently.
  4. Is this a regression? git log --oneline -20 — when did it last work?

If you can't reproduce it: Stop. Gather more information. Unreproducible bugs are unsolvable.

Phase 2 — Isolate

Goal: Narrow the search space to the smallest possible area.

  1. Identify the layers involved: UI → API → service → DB → external?
  2. Test each boundary — where does correct input produce wrong output?
  3. Binary-search the call stack: disable half, does the bug disappear?
  4. Is it environment-specific? dev vs prod? one machine vs all?

Isolation heuristics:

  • Works in tests, breaks live → check environment (config, secrets, timing)
  • Started after a deploy → git bisect
  • Intermittent → look for shared mutable state, races, time-dependent logic

Phase 3 — Hypothesize

State one falsifiable hypothesis before changing any code:

Hypothesis  : [what I think is wrong]
Evidence for: [what supports this]
Against     : [what doesn't fit]
Test        : [one action that confirms or refutes]

One hypothesis at a time. Testing multiple simultaneously makes it impossible to know what fixed it.

Phase 4 — Verify

  1. Run the test that confirms or refutes.
  2. Confirmed → move to fix.
  3. Refuted → form a new hypothesis. Don't modify the failing thing yet.
  4. Keep a short log: what you tried, what you learned.

Phase 5 — Fix

  1. Make the minimal change that fixes the root cause — not the symptom.
  2. Run the full test suite.
  3. Add a regression test that would have caught this bug.
  4. Commit message explains why, not just what:
    fix: [what was broken]
    
    Root cause: [why it happened]
    Fix: [what changed and why this is correct]

COMMON BUG PATTERNS

PatternSymptomWhere to look
Off-by-oneWrong last/first elementLoop bounds, slice indices, pagination
Nil/null dereferenceCrash on accessUnguarded pointer use, missing null checks
Race conditionIntermittent, timing-dependentShared state, goroutines/threads, async code
Wrong input assumptionsWorks in tests, breaks in prodInput validation, edge cases, empty/max values
Config/env mismatchWorks locally, breaks in CI/prod.env files, env var names, defaults
Stale stateShows old dataCaches, memoization, DB transaction isolation
Type coercionWrong math, unexpected falsyJS ==, int/float truncation, string/int mixing
Dependency versionBroke after upgradeChangelog, breaking changes, peer dependencies

REGRESSION TEST FORMAT

// Regression: [short description of what was broken]
// Arrange: exact conditions that triggered the bug
// Act:     the action that was broken
// Assert:  the correct outcome

The test must reproduce the exact failing scenario, not a simplified analogue.


RULES

  • Reproduce before touching code. A fix without reproduction is a guess.
  • One change at a time. Multiple simultaneous changes make causation unknowable.
  • Fix the root cause, not the symptom. Wrapping a bug in an if is not a fix.
  • Always add a regression test. If it broke once, it can break again.
  • git bisect for regressions. Faster than reading the diff.
  • Tag unverified claims [hypothesis] when communicating status.

PROJECT QUICK REFERENCE

Stack: Go [inferred — no go.mod yet; project in planning stage as of 2026-06-25]

Test commands

# Run all
go test ./...

# Run all with race detector (preferred)
go test -race ./...

# Run single package
go test ./internal/mine/...

# Run single test by name
go test ./internal/mine/... -run TestChunkFilter

# Coverage
go test -cover ./...

# Verbose output (shows each test name)
go test -v ./...

Debug logging

No debug env vars in source yet [project pre-implementation]. When adding:

  • Use os.Getenv("SESSION_INDEXER_DEBUG") or similar for verbose output
  • Ollama probe failures already log to stderr: warn: ollama unavailable, indexed without embeddings
  • SQLite errors surface via returned error — check err != nil after every DB call

To manually inspect the SQLite DB:

# Open index
sqlite3 .claude/sessions.db

# Check schema version
SELECT * FROM meta;

# Count chunks and pending embeddings
SELECT COUNT(*) FROM chunks;
SELECT COUNT(*) FROM chunks WHERE id NOT IN (SELECT chunk_id FROM embeddings);

# WAL checkpoint status
PRAGMA wal_checkpoint;

Known fragile areas

Derived from architecture docs — no git history yet:

AreaFile (planned)Risk
JSONL parsinginternal/mine/parse.goBinary heuristic for tool_result (len>10KB or base64 pattern); tool block 2KB truncation edge cases
Noise filterinternal/mine/chunk.goStrips chunks <30 chars after strip — easy to over-filter multilingual content
Dedup logicinternal/mine/mine.goINSERT OR IGNORE on (session_id, message_index, chunk_index) — if session_id is absent from JSONL, falls back to filename stem; mismatch = duplicates
Ollama probeinternal/embed/embed.go2s timeout on GET /api/tags; bge-m3:latest model-name match is exact string — version suffix in tag list will fail silently
Float32 BLOBinternal/embed/embed.goencoding/binary LittleEndian; corrupted BLOB = cosine NaN; check len(blob) % 4 == 0 and len(blob) == 4096
Schema versioninternal/db/db.goHard exit on mismatch — if user has old DB, they must run reindex; no migration path
FTS5 syncinternal/db/schema.sqlTriggers keep FTS5 in sync; if trigger fires after content delete without FTS delete → phantom results
Search fallbackinternal/search/search.goCosine over all embeddings loaded into memory — at 10k+ chunks this is ~40MB; no pagination

Stack-specific debug notes

Pure Go / no CGO:

  • modernc.org/sqlite — no system libsqlite3 needed; if build fails with sqlite errors, check go.mod replaces or proxy issues
  • Race detector (-race) is safe to run — no CGO exclusions needed

Ollama connectivity:

# Is Ollama running?
curl -s http://localhost:11434/api/tags | jq '.models[].name'

# Is bge-m3 available?
curl -s http://localhost:11434/api/tags | jq '[.models[].name] | map(select(startswith("bge-m3")))'

# Manual embed test
curl -s -X POST http://localhost:11434/api/embed \
  -d '{"model":"bge-m3:latest","input":"test"}' | jq '.embeddings[0] | length'
# Expected: 1024

SQLite WAL:

# If reads appear stale after write
PRAGMA wal_checkpoint(FULL);

# Check WAL file size (>10MB = checkpoint not running)
ls -lh .claude/sessions.db-wal

Stop hook timing:

  • Hook timeout = 60s; mine must complete within it
  • To time a real mine run: time session-indexer mine <jsonl> --db .claude/sessions.db
  • If Ollama is slow, embedding 100 chunks can hit ~30s; test with --skip-embed flag if added

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.