Skip to main content

Hardware Context Compiler — transforms hardware docs into AI-optimized context

Project description

hwcc — Hardware Context Compiler

AI coding tools already read everything in your repo — source code, Makefiles, configs. But they can't read the vendor PDF on your desk. They hallucinate register addresses, get init sequences wrong, and miss errata.

hwcc fixes this. It transforms hardware documentation (datasheets, SVD files, reference manuals, device trees) into AI-optimized context files that any coding tool can consume — Claude Code, Codex, Cursor, Gemini CLI, or Copilot.

Install

pipx install hwcc

Or with pip (in a virtual environment):

pip install hwcc

Requires Python 3.11+. No API keys needed — runs 100% locally by default.

Quick Start

# Initialize in your project
cd my-firmware-project
hwcc init --chip STM32F407

# Add hardware documentation
hwcc add docs/STM32F407.svd
hwcc add docs/reference-manual.pdf
hwcc add docs/errata.pdf

# Check what's indexed
hwcc status

That's it. hwcc add automatically compiles context into your CLAUDE.md (and other tool files) with hardware register maps, peripheral details, and coding conventions — all between safe <!-- BEGIN/END HWCC CONTEXT --> markers that never touch your existing content.

What It Produces

After hwcc add, your project gets:

File Tool Content
CLAUDE.md Claude Code Hardware context section
AGENTS.md Codex CLI Same context, Codex format
.cursor/rules/hardware.mdc Cursor Cursor rules format
.gemini/GEMINI.md Gemini CLI Gemini format
.github/copilot-instructions.md GitHub Copilot Copilot format

Plus internal context files in .rag/context/:

  • hot.md — Concise hardware summary (~120 lines), always loaded
  • peripherals/*.md — Per-peripheral deep context (registers, usage patterns, errata)

Supported Documents

Format What It Extracts
.svd Register maps with bit-fields, reset values, access types
.pdf Text + tables from datasheets, reference manuals, errata
.dts / .dtsi Device tree topology, peripheral nodes, pin configs
.md / .txt Passthrough (application notes, custom docs)

Commands

hwcc init [--chip <mcu>]                Initialize project
hwcc add <file> [--type <type>]         Add document(s) to index
hwcc remove <doc_id>                    Remove a document
hwcc status                             Show project status
hwcc compile [--target <tool>]          Regenerate context files
hwcc version                            Show version

Useful Options

# Add with explicit chip tag (useful for multi-chip projects)
hwcc add power-ic.pdf --chip TPS65217

# Compile for a specific tool only
hwcc compile --target claude

# Skip auto-compile after adding (compile manually later)
hwcc add docs/*.svd --no-compile

Configuration

hwcc init creates .rag/config.toml:

[project]
name = "motor-controller"

[hardware]
mcu = "STM32F407VGT6"
mcu_family = "STM32F4"

[software]
rtos = "FreeRTOS 10.5.1"
hal = "STM32 HAL v1.27.1"

[conventions]
register_access = "HAL functions only, no direct register writes"

[embedding]
provider = "chromadb"  # Default: built-in, zero-config

[output]
targets = ["claude", "codex", "cursor", "gemini"]

Edit this file to tune what context gets generated.

Example Output

See examples/stm32f407-motor/ for a complete sample project with pre-generated output. Key files:

How It Works

Raw Docs → Parse → Chunk → Embed → Store → Compile → Output Files
             |        |       |       |         |
           SVD/PDF  512-tok  ONNX  ChromaDB  Jinja2 templates
           parser   splits   local  vectors   per-tool output

All processing is deterministic and local. No LLM calls in the core pipeline. Embedding uses ChromaDB's built-in ONNX model (all-MiniLM-L6-v2) — zero configuration needed.

Why Not Just Give the AI the PDF?

  • PDFs are huge (500+ pages). Context windows are expensive and lossy.
  • SVD register data is structured — parsing it deterministically is more reliable than LLM extraction.
  • Pre-compiled context survives context compaction (Claude Code's auto-compaction can drop raw PDFs).
  • RAG is ~1,250x cheaper than stuffing full documents into every prompt.

Development

git clone https://github.com/Ecro/hwcc.git
cd hwcc
pip install -e ".[dev]"

pytest tests/           # 675 tests
ruff check src/ tests/  # lint
mypy src/hwcc/          # type check

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hwcc-0.2.0.tar.gz (316.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hwcc-0.2.0-py3-none-any.whl (125.1 kB view details)

Uploaded Python 3

File details

Details for the file hwcc-0.2.0.tar.gz.

File metadata

  • Download URL: hwcc-0.2.0.tar.gz
  • Upload date:
  • Size: 316.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for hwcc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6c23ccb48b73fedf178831271f3aa0432d16809f54c71cf0af98fc21ebc044a3
MD5 bd3918153a93246efe3c157a6a368820
BLAKE2b-256 82a322757583ca518a7a6c26aa6c2f4f1d79b01422457dba9bcc229c7ce2bfb3

See more details on using hashes here.

File details

Details for the file hwcc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: hwcc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 125.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for hwcc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cba380f0c00eb013bcdf542233216cab4221d6c33032487d6d2fac31bd3737c
MD5 d7afa85fcddc271ce7268753aff06bfa
BLAKE2b-256 2639f7374fd0e3c4ed1a58e50236fbec5305ff787fac1e483b3f1d9abbaf988b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page