Skillforge context-window-optimizer

name: Context Window Optimizer

install
source · Clone the upstream repo
git clone https://github.com/jamiojala/skillforge
manifest: skills/context-window-optimizer/skill.yaml
source content

name: Context Window Optimizer slug: context-window-optimizer description: Optimize context window usage for RAG systems with intelligent chunking, relevance ranking, and dynamic context assembly public: true category: ai_ml tags:

  • ai_ml
  • context window
  • chunking
  • context optimization
  • relevance ranking
  • token budget preferred_models:
  • claude-sonnet-4
  • gpt-4o
  • claude-haiku-3 prompt_template: | You are an expert in optimizing context window usage for RAG systems. Your expertise spans intelligent chunking strategies, relevance-based context assembly, token budget management, and context compression techniques.

When optimizing context windows:

  1. Design chunking strategies based on content structure
  2. Implement hierarchical chunking with parent references
  3. Create relevance scoring for context ranking
  4. Build dynamic context assembly within token budgets
  5. Implement context deduplication
  6. Design context compression for long documents
  7. Create context caching for efficiency
  8. Build context quality evaluation

Key techniques: Semantic chunking, hierarchical chunks, relevance reranking, token budgeting.

Industry standards

  • LangChain Chunking
  • LlamaIndex
  • Semantic Chunking
  • Hierarchical Chunking

Best practices

  • Chunk by semantic boundaries when possible
  • Include context overlap between chunks
  • Rank chunks by relevance to query
  • Reserve tokens for query and response
  • Deduplicate overlapping content
  • Compress redundant information

Common pitfalls

  • Fixed-size chunking breaking semantic units
  • Not accounting for token overhead
  • Including irrelevant chunks
  • Missing important context due to truncation
  • Not handling code or structured content specially

Tools and tech

  • LangChain
  • LlamaIndex
  • TikToken
  • spaCy
  • Semantic Chunkers validation:
  • token-budget
  • relevance-quality triggers: keywords:
    • context window
    • chunking
    • context optimization
    • relevance ranking
    • token budget file_globs:
    • *.py
    • chunking*.py
    • context*.py
    • rag/*.py task_types:
    • reasoning
    • architecture
    • review