Back to all posts

Introducing fetch-context

A Claude/Codex skill for pulling library docs, upstream source, and web pages into the working directory.

projectsai-assisted

Update (2026-06-13): I've leaned on this skill so heavily since publishing that I extracted the underlying logic into a standalone binary: fetch-context. The skill now wraps the CLI rather than reimplementing the fetch logic inline.

fetch-context is a skill — installable into Claude Code or Codex via skillvendor — that gives an agent three deliberate paths for bringing external context into the current repo:

  1. Docs via context7-cli — curated, up-to-date library documentation. The agent searches for a library ID, then pulls docs by ID.
  2. Source via shallow git clone into .agentic/sources/<repo>/ — the upstream project lands on disk, ready for Read/Grep/Glob, scoped to the repo and gitignored.
  3. URL via https://r.jina.ai/ — wrap any URL to get a clean markdown rendering, much friendlier than raw HTML.

The three modes map directly to three things I kept reaching for:

  • Replicating patterns. Pointing at a repo and saying "organize the Terraform here the way that one does" — pick your own $X. A source clone makes the upstream greppable alongside mine, so the agent can mirror conventions without me copy-pasting files. Aside: this is excellent for infrastructure-as-code — Helm charts, Terraform modules, Kustomize overlays, GitHub Actions workflows. The "right" structure is largely convention, the conventions live in real repos, and an agent with the source on disk can absorb them in one pass.
  • Detailed open-source investigation. Adding a workflow against a library like Mastra (just one example — could equally be any SDK, framework, or CLI), debugging a quirky API call, tracing why a dependency does what it does. These all need implementation detail the docs don't cover. Cloning the source locally turns "read the code" into a one-line ask.
  • Better web retrieval. Whether it's a changelog, an RFC, a vendor docs page, or a blog post — built-in fetch tools tend to choke on heavy pages or hand back HTML soup. Routing through r.jina.ai consistently produces markdown the agent can actually reason over.

The skill itself is mostly a decision guide — when to reach for which path, how to write a good Context7 query, where to drop clones so they don't pollute the host repo, what not to send to third-party proxies. The bash commands are simple; the value is in the agent picking the right tool and using it well.

Grab it from the skills repo, or vendor it with skillvendor.


This post was drafted in collaboration with Claude Opus 4.7. Attributing when AI is part of the brainstorming or writing process and tagging those posts w/ ai-assisted.