This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Bond CLI is a Python command-line tool for interacting with Bond Home automation devices. It provides commands for device discovery, management, firmware upgrades, and diagnostics.
pip install -e "." # Install in editable mode
pip install -r requirements-test.txt # Install test dependenciespytest # Run all tests with coverage
pytest bond/database/test_database.py # Run specific test file
pytest -k "test_name" # Run tests matching patternflake8 . --count --max-line-length=127 --statisticsbond discover # Find Bonds on network
bond select <bond-id> # Select active Bond
bond -h # Show all commandsCommands are registered in bond/app.py and live in bond/commands/. Each command module exposes:
help/description- Help textrun(args)- Execution functionsetup(parser)- Optional argparse setuparguments- Dict of argument definitionssubcommands- List of nested subcommands (for commands likedevices,groups,wifi)
http.py- HTTP transport to Bond REST API (/v2/endpoints)mdns.py- mDNS discovery using zeroconf (_bond._tcp.local.)wye.py- High-level facade exposingget(),post(),put(),patch(),delete()base_transport.py- Async support viarequest_async()with callbacks
Singleton JSON database at ~/.bond/db.json stores:
- Selected Bond ID
- Discovered Bond metadata (IP, port, token)
- Per-Bond settings
Uses MutableMapping interface with thread-safe RLock.
main.py- argparse-based command dispatcherconsole.py- Thread-safe queue-based output with ANSI color supporttable.py- Fixed-width table formatting
Adding a new command: Create module in bond/commands/, register in bond/app.py via load_command().
Async requests: Use request_async(method, bondid, on_success=callback, on_error=callback) from protocol layer.
Token authentication: Token passed in BOND-Token header. Can be retrieved via PIN unlock or set manually.
- Tests run on Python 3.7, 3.8, 3.9
- Releases: bump version in
setup.py, create annotated git tag (git tag -a "vX.Y.Z"), push to trigger PyPI deployment