Quick Start
Installation
Install ContextMD globally via npm to use it as a CLI utility across your projects:
npm install -g contextmd-cli
Prerequisites
To use the AI-powered refinement feature, you will need an OpenAI API Key. You can provide this in two ways:
- Environment Variable: Add
OPENAI_API_KEY=your_key_hereto your.envfile or export it in your terminal. - CLI Flag: Use the
--keyor-kflag when running the command.
Your First Crawl
Convert any documentation site into a single context file in one command. By default, ContextMD crawls up to 100 pages and saves the result to context.md.
contextmd https://docs.example.com --key sk-...
Common Options
Customize the crawl behavior using the following flags:
| Flag | Description | Default |
| :--- | :--- | :--- |
| -o, --output <path> | Define the output filename or path. | context.md |
| -l, --limit <number> | Set the maximum number of pages to crawl. | 100 |
| -k, --key <key> | Your OpenAI API Key. | process.env.OPENAI_API_KEY |
Example: Advanced Usage
To crawl a specific version of a documentation site with a page limit and custom output name:
contextmd https://docs.example.com/v2/api -l 50 -o example-v2-context.md
How it Works
- Crawl: The utility traverses the provided URL, staying within the same domain and identifying all relevant sub-pages.
- Clean: It strips away non-essential HTML elements like navigation bars, footers, and scripts.
- Refine: Using
gpt-4o-mini, it rewrites the content into high-density Markdown specifically optimized for LLM comprehension. - Consolidate: All processed pages are merged into a single structured file, ready to be uploaded to your AI Agent or LLM chat.
Usage Tip
Once your context.md is generated, drop it into your prompt or knowledge base.
Prompt Example:
"Using the attached
context.mdas your primary source of truth, explain how to implement the authentication flow described in the API documentation."