Skip to content

Add 'know context' command for semantic session context loading #88

@jordanpartridge

Description

@jordanpartridge

Problem

Current session hooks use static CLAUDE.md files for project context. This means:

  • Context gets stale over time
  • No semantic relevance - just dumps entire file
  • Can't auto-discover patterns from knowledge base
  • No ranking by usage/recency/confidence

Proposed Solution

Add ./know context command that semantically searches Qdrant for relevant project context.

Features

  1. Auto-detect project from git repo or directory name
  2. Smart search for:
    • Recent decisions (updated_at DESC)
    • High-usage patterns (usage_count DESC)
    • Project-specific architecture (module=<project>)
    • Common gotchas (category=gotcha)
  3. Rank by relevance:
    • Recently accessed = still relevant
    • High confidence = vetted knowledge
    • Frequently used = proven patterns
  4. Format for Claude:
    • Concise summaries with links to full details
    • Grouped by category (architecture, patterns, decisions, gotchas)
    • Token-aware (max-tokens flag to fit context window)

Usage

# Auto-detect project and generate context
./know context

# Specify project explicitly
./know context --project=conduit-ui

# Limit output tokens for session hooks
./know context --max-tokens=2000

# Filter by specific categories
./know context --categories=architecture,patterns

Session Hook Integration

#!/bin/bash
# ~/.claude/hooks/session-start.sh
./know context --project="$(basename "$PWD")" --max-tokens=2000

Implementation Notes

  • Use QdrantService search with filters
  • Group results by category
  • Format as markdown with summary sections
  • Track which entries are used (increment usage_count)
  • Consider caching recent context lookups

Acceptance Criteria

  • ./know context command exists and works
  • Auto-detects project from pwd/git
  • Searches Qdrant with smart ranking
  • Formats output for Claude consumption
  • Respects --max-tokens limit
  • Increments usage_count for accessed entries
  • Has comprehensive tests
  • Documentation in README

Benefits

  • Dynamic context that evolves with your knowledge base
  • Semantic relevance instead of static dumps
  • Token-efficient - only includes what matters
  • Self-improving - tracks what context is actually useful (usage_count)
  • Multi-project - works across all your projects automatically

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions