Skip to main content

contaix

Tools to make contexts (knowledge bases) for AI.

contaix turns diverse sources — code repos, documentation sites, file collections — into clean markdown contexts for AI agents to consume.

pip install contaix

Skills

This package ships agent skills you can install into any agent host with gh skill (don't have it? install gh):

gh skill install thorwhalen/contaix contaix-acquire-docs --agent claude-code
gh skill install thorwhalen/contaix contaix_docs_to_markdown
gh skill install thorwhalen/contaix contaix_web_aggregate
Skill Use it when…
contaix-acquire-docs acquiring a tool's docs (plus OpenAPI/MCP/GraphQL specs) as one agent-ready markdown bundle, cheapest source first
contaix_docs_to_markdown converting a documentation website into a single clean markdown file
contaix_web_aggregate aggregating arbitrary (non-docs) web pages into structured markdown, with manual control

Quick Start

Documentation site → single markdown file

from contaix.web import site_to_markdown

site_to_markdown(
    "https://fal.ai/docs/documentation",
    output_file="~/Downloads/fal_ai_docs.md",
    verbose=True,
)

site_to_markdown first probes the site for a publisher-provided /llms-full.txt bundle (Mintlify, Docusaurus, Fern, and others ship one). If found, it returns that directly — one HTTP request, clean markdown, no scraping. Otherwise it falls back to discovering navigation, fetching every page (with caching), and aggregating.

To bypass the fast path or grab the bundle yourself:

from contaix.web import find_llms_full_url, fetch_llms_full

bundle_url = find_llms_full_url("https://fal.ai/docs")  # str or None
markdown = fetch_llms_full("https://fal.ai/docs")  # str or None

Code base → single markdown file

from contaix import code_aggregate

# A local package
md = code_aggregate("contaix")

# A directory
md = code_aggregate("/path/to/project")

# A GitHub repo (downloaded via hubcap)
md = code_aggregate("https://github.com/thorwhalen/contaix")

# Save instead of return
code_aggregate("contaix", egress="/tmp/contaix_code.md")

Files → markdown

from contaix import bytes_to_markdown, bytes_store_to_markdown_store
from dol import Files

# Single file (auto-detects format)
md = bytes_to_markdown(open("report.pdf", "rb").read(), input_format="pdf")

# A whole folder
src = Files("/path/to/documents")
target = {}
bytes_store_to_markdown_store(src, target)

Markdown conversion is delegated to dn.src and supports PDF, DOCX, XLSX, PPTX, HTML, IPYNB, and more.

Cleanup of messy markdown (e.g. ChatGPT exports)

from contaix import remove_hyperlink_crap, remove_improperly_double_newlines

# Reads from clipboard if no arg, copies result back
clean = remove_hyperlink_crap()

Pure transforms live in dn.repair; the contaix wrappers add clipboard integration.

URLs in prose → article PDFs

from contaix import extract_urls, download_articles, verify_urls

# Inspect what URLs are in a string
list(extract_urls("[OpenAI](https://openai.com) and https://anthropic.com"))
# -> [('OpenAI', 'https://openai.com'), ('https://anthropic.com', 'https://anthropic.com')]

# Verify they resolve
verify_urls(["https://openai.com", "https://anthropic.com"])
# -> {'https://openai.com': 200, 'https://anthropic.com': 200}

# Download as PDFs (delegates to pdfdol)
download_articles(some_md_string, save_dir="~/Downloads/articles")

Package Map

contaix/
  web.py           # site_to_markdown, find_llms_full_url, RSC extraction
  code.py          # code_aggregate, PackageCodeContexts, GitHub fetch
  markdown.py      # bytes_to_markdown (delegates to dn.src)
  urls.py          # extract_urls, verify_urls, download_articles
  aggregation.py   # aggregate_store with deduplication and chunking
  util.py          # markdown_of_site, scrape utilities, clipboard helpers
  skills.py        # discover/install OTHER ecosystem packages' skills

contaix's own agent skills live at the repo root in skills/ (gh-distributed — see the Skills section above), symlinked into .claude/skills/.

Architecture

  • Functions are the primary interface; classes are reserved for stateful workflows (e.g. PackageCodeContexts).
  • dol store abstractions for file/data access throughout.
  • Smart defaults with keyword-only configurability — out of the box for common cases, fully parameterizable when needed.
  • Pure transforms live in domain packages (dn, pdfdol); contaix is the orchestration and UX layer.

Optional dependencies

  • pdfdol — for download_articles and PDF round-trips (pip install contaix[pdf])
  • dn[all] — for the full set of file-format converters (pip install contaix[all])
  • dn — pure markdown conversion and repair
  • pdfdol — PDF reading, writing, and format conversion
  • dol — store abstractions used everywhere
  • scraped — scraping primitives
  • hubcap — GitHub repo access

Metadata

Release files for contaix 0.0.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contaix 0.0.21
File Size Uploaded
contaix-0.0.21.tar.gz 201.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for contaix 0.0.21
File Interpreter ABI Platform
contaix-0.0.21-py3-none-any.whl Python 3 none any Details

Total release size: 371.6 kB

Release files / contaix-0.0.21.tar.gz

Download URL contaix-0.0.21.tar.gz
Size 201.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0ae2824933f808bce89fce8a5fc05873e7d644aa613856ad716e41ffe22e82e4
BLAKE2b-256 checksum
How to use checksums
80e2b70d02dd604287a3d15db717d021401301bb547348988d6e35e17ed82a7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / contaix-0.0.21-py3-none-any.whl

Download URL contaix-0.0.21-py3-none-any.whl
Size 170.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c0dbd52f78f8901d8318ca0f192b5262875c60df8cfb04096a36844efdc1d03
BLAKE2b-256 checksum
How to use checksums
64e894976628e896ca680080de8bbb4860a9889247047da4ea5e4ba02238df57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.0.21 This release

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page