This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
hier-config-cli is a Click-based CLI tool for network configuration analysis built on the hier-config library. It compares running and intended device configs to generate remediation, rollback, and future-state configurations. Supports 10 network platforms (Cisco IOS/NXOS/XR, Arista EOS, Juniper JunOS, VyOS, FortiOS, HP Comware5/ProCurve, Generic).
# Install dependencies
poetry install
# Run all tests with coverage
pytest
# Run a single test
pytest tests/test_cli.py::test_version
# Code formatting
black src/ tests/
# Linting
ruff check src/ tests/
# Type checking
mypy src/
# All quality checks
black src/ tests/ && ruff check src/ tests/ && mypy src/ && pytestThe entire CLI lives in a single module: src/hier_config_cli/__main__.py. The entry point is the cli() Click group, registered as hier-config-cli in pyproject.toml.
Key flow: All three config commands (remediation, rollback, future) share the same pattern:
common_optionsdecorator applies shared Click options (platform, running-config, generated-config, format, output)process_configs()validates the platform, reads both config files viahier_config.utils.read_text_from_file, parses them withget_hconfig(), then runs the requested operation viaWorkflowRemediation(for remediation/rollback) orHConfig.future()(for future)format_output()converts the result HConfig to text/JSON/YAMLget_output_text()handles platform-specific formatting — JunOS usesline.text, all others useline.cisco_style_text()
PLATFORM_MAP dict maps CLI string names to hier_config.Platform enum values. To add a new platform, add it here, handle any special output formatting in get_output_text(), and add tests.
- Python 3.10+ (uses
X | Yunion syntax) - Black formatter, 100-char line length
- Ruff linter rules: E, W, F, I, B, C4, UP
- mypy strict mode (all functions must have type hints)
- Google-style docstrings
- Conventional commits:
feat:,fix:,docs:,test:,refactor:
Tests use Click's CliRunner for CLI invocation testing. Fixtures provide mock Cisco IOS and Juniper JunOS configs via temporary files. The test suite covers all commands, output formats, all platforms, error handling, and logging levels.
test-app.yaml: Runs black, ruff, mypy, and pytest on Python 3.10–3.13 for every push/PR to maindeploy.yaml: Publishes to PyPI via Poetry on GitHub release creation- Version is maintained in both
pyproject.tomland__main__.py:__version__