Curated, Versioned Context for AI Coding Agents
andrewyng/context-hub · 11.2k stars · JavaScript
agent37.club
Two fundamental failures plague every AI coding agent:
Agents generate plausible-looking but non-existent function signatures, parameters, and return types. The code compiles in their imagination, not in reality.
Every conversation starts from zero. Workarounds discovered at 2am are forgotten by morning. There is no persistent memory between sessions.
# Agent confidently writes: from stripe import PaymentProcessor # This class doesn't exist. # The real import is: import stripe stripe.PaymentIntent.create() # Agent discovers this, fixes it. # Next session? Same mistake.
All content is plain markdown on GitHub. Users can inspect exactly what their agents read — no black boxes.
All five layers work together to create a self-improving documentation system.
| Command | Purpose | Key Flags |
|---|---|---|
| chub search [query] | Discover available docs/skills | Empty query lists all |
| chub get <id> | Fetch documentation by ID | --lang py|js, --file, --full |
| chub annotate <id> <note> | Attach persistent local note | --clear, --list |
| chub feedback <id> up|down | Rate doc quality for authors | |
| chub help | Show all commands and usage |
The CLI output is structured for LLM consumption. Agents are prompted to run chub help to self-discover capabilities.
# Broad search $ chub search "stripe" Found 3 results: stripe/api Stripe API reference stripe/webhooks Webhook handling guide stripe/checkout Checkout integration # List everything available $ chub search All available content (47 items): openai/chat OpenAI Chat Completions openai/embeddings Embedding API stripe/api Stripe API reference ...
Search returns only IDs and descriptions — not full content. The agent decides what to fetch.
# Default: main doc only $ chub get openai/chat --lang py # Specific reference file $ chub get openai/chat --file streaming # Everything (all references) $ chub get openai/chat --full
Each doc can have multiple reference files — the agent fetches only the section relevant to its current task.
Approximate token counts for typical API documentation.
# Python variant $ chub get openai/chat --lang py # JavaScript variant $ chub get openai/chat --lang js
Documentation is maintained per-language, not as a one-size-fits-all reference. Each variant includes:
When an agent asks for the Python Stripe docs, it gets the exact import stripe pattern — not the JavaScript require('stripe') mixed in.
Language confusion is one of the top sources of hallucinated APIs.
# Agent discovers a gotcha $ chub annotate stripe/webhooks \ "Must use raw request body, not parsed JSON, for signature verification. See: express raw() middleware." # Next session: annotation appears # automatically when fetching docs $ chub get stripe/webhooks [Content + local annotations shown] # Manage annotations $ chub annotate --list $ chub annotate stripe/webhooks --clear
This turns a stateless tool into a stateful knowledge base. Each project accumulates tribal knowledge that persists indefinitely.
# Agent found docs helpful $ chub feedback openai/chat up # Agent found docs incomplete $ chub feedback stripe/api down
Votes are aggregated and surfaced to content authors. This creates a signal for which docs need improvement.
--- id: openai/chat title: Chat Completions API version: 2024.1 languages: [py, js] references: - streaming - function-calling - vision --- # Chat Completions Create chat completions using the OpenAI API... ## Basic Usage ...
content/ openai/ chat/ index.md # main doc py.md # Python variant js.md # JS variant streaming.md # reference file function-calling.md stripe/ api/ index.md py.md webhooks.md
Submit content via pull requests. API providers, framework authors, and community members all contribute.
Agents discover Context Hub through a skill file that teaches them when and how to use it:
# For Claude Code: mkdir -p ~/.claude/skills/get-api-docs cp SKILL.md ~/.claude/skills/get-api-docs/ # The SKILL.md tells the agent: # 1. When to use chub (API questions) # 2. How to search and fetch # 3. When to annotate findings # 4. When to provide feedback
Scope: Your machine, your projects
Speed: Immediate — available next session
Content: Workarounds, gotchas, project-specific notes
Think of it as the agent's personal notebook. Each project accumulates its own knowledge base.
Scope: All users of Context Hub
Speed: Slower — requires author action
Content: Quality signals, missing sections, incorrect examples
Aggregated votes guide authors toward the highest-impact improvements. Everyone benefits.
Local annotations handle the long tail of project-specific knowledge. Global feedback improves the shared baseline for everyone. Both together create a system that gets better at every scale.
| Source | Tokens | Signal:Noise |
|---|---|---|
| Full web page | ~15k | Low (ads, nav, boilerplate) |
| Raw API docs | ~10k | Medium (all endpoints) |
| Context Hub full | ~6k | High (curated) |
| Context Hub targeted | ~2k | Very high (specific section) |
A typical coding session might reference 5-10 APIs. At 15k tokens each from web scraping, that is 75-150k tokens of context consumed.
With Context Hub targeted fetch: 10-20k tokens. That is a 7-8x reduction in context window consumption.
| Approach | Accuracy | Persistence | Token Cost | Maintenance |
|---|---|---|---|---|
| Training data only | Hallucinations | None | Zero | None |
| Web search (RAG) | Variable | None | High | None |
| Copy-paste in prompt | Good | Manual | Very high | Heavy |
| Context Hub | Curated | Annotations | Low | Community |
Context Hub sits between "trust the model's memory" (cheap but unreliable) and "paste everything into the prompt" (accurate but expensive). It gives agents on-demand access to verified knowledge.
npm install -g @aisuite/chub # Verify chub --version chub help
// Simplified flow: // 1. Parse doc ID + flags const { id, lang, file } = parseArgs(); // 2. Resolve content path const path = resolve( `content/${id}/${lang || 'index'}.md` ); // 3. Fetch from GitHub const content = await fetchContent(path); // 4. Merge local annotations const annotations = getAnnotations(id); // 5. Return combined output return format(content, annotations);
Context Hub is part of Andrew Ng's aisuite project — a collection of tools for building reliable AI agents.
The philosophy: agents need infrastructure, not just prompts. Better tools make better agents.
"Agentic AI is the next frontier. But agents need reliable knowledge retrieval, not just bigger models."
Context Hub embodies this: improve agent output by improving agent inputs.
# Agent hallucinates: from stripe.checkout import Session session = Session("price_123") session.redirect_url = "/success" session.create() # ImportError: No module named # 'stripe.checkout' # Agent tries 3 more wrong versions # before getting it right...
# Agent fetches docs first: # $ chub get stripe/checkout --lang py import stripe session = stripe.checkout.Session.create( line_items=[{ "price": "price_123", "quantity": 1, }], mode="payment", success_url="https://...", ) # Works on first try.
# 1. Fork the repo git clone andrewyng/context-hub # 2. Add content mkdir -p content/myapi/ # Write markdown with YAML frontmatter # 3. Submit PR git push && gh pr create # Content guide in repo explains # frontmatter format and conventions
Content is plain text in a Git repo. Anyone can read it, diff it, review it. No proprietary format, no vendor lock-in.
Agents already have shell access. A CLI is the simplest interface — no authentication, no API keys, no rate limits to manage.
Privacy by default. Your agent's notes never leave your machine. No accounts, no telemetry on content.
Token budgets are real constraints. Fetching only what you need is not just efficient — it keeps the agent focused.
Context Hub is an early example of agent infrastructure — tools built not for humans to use, but for AI agents to use.
As agents become more capable, the bottleneck shifts from model intelligence to reliable knowledge retrieval. This is the infrastructure layer being built.
Better inputs beat bigger models. Curated docs eliminate hallucination at the source.
Annotations turn stateless agents into learning systems. Knowledge accumulates across sessions.
The open-source model that works for code also works for agent knowledge. Feedback loops keep content fresh.
Tools designed for agents (not humans) to use. Context Hub is early but points to where the ecosystem is heading.
Curated, Versioned Context for AI Coding Agents
npm install -g @aisuite/chub
github.com/andrewyng/context-hub
agent37.club