Installation
Installation
ContextMD is distributed via NPM as a command-line interface (CLI). You can install it globally on your machine or run it instantly using npx.
Prerequisites
Before installing, ensure you have the following:
- Node.js: Version 18.0.0 or higher.
- OpenAI API Key: ContextMD uses
gpt-4o-minito refine and compress documentation. You can obtain a key from the OpenAI Dashboard.
Global Installation
To use the contextmd command from anywhere in your terminal, install the package globally:
npm install -g contextmd-cli
Once installed, verify the installation by checking the version:
contextmd --version
Run via npx (No Installation Required)
If you prefer not to install the package globally, you can run ContextMD directly using npx:
npx contextmd-cli <url> [options]
Configuration
ContextMD requires an OpenAI API key to process and refine the crawled content. You can provide this key in two ways:
1. Environment Variable (Recommended)
Add your key to your shell profile (e.g., .zshrc or .bashrc) or create a .env file in your working directory:
export OPENAI_API_KEY='your_api_key_here'
2. CLI Flag
Pass the key directly during execution using the -k or --key flag:
contextmd https://docs.example.com --key your_api_key_here
Quick Start
Once installed, you can generate your first context file by pointing the utility at a documentation URL:
contextmd https://docs.python.org/3/library/unittest.html
By default, this will crawl up to 100 pages and output a consolidated context.md file in your current directory.