|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Infrahub Python SDK - async/sync client for Infrahub infrastructure management. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +uv sync --all-groups --all-extras # Install all deps |
| 9 | +uv run invoke format # Format code |
| 10 | +uv run invoke lint # Lint (ruff + mypy + yamllint) |
| 11 | +uv run pytest tests/unit/ # Unit tests |
| 12 | +uv run pytest tests/integration/ # Integration tests |
| 13 | +``` |
| 14 | + |
| 15 | +## Tech Stack |
| 16 | + |
| 17 | +Python 3.10-3.13, UV, pydantic >=2.0, httpx, graphql-core |
| 18 | + |
| 19 | +## Code Pattern |
| 20 | + |
| 21 | +```python |
| 22 | +# Always provide both async and sync versions |
| 23 | +client = InfrahubClient() # async |
| 24 | +client = InfrahubClientSync() # sync |
| 25 | + |
| 26 | +node = await client.get(kind="NetworkDevice") |
| 27 | +await node.save() |
| 28 | +``` |
| 29 | + |
| 30 | +## Project Structure |
| 31 | + |
| 32 | +```text |
| 33 | +infrahub_sdk/ |
| 34 | +├── client.py # Main client implementations |
| 35 | +├── config.py # Pydantic configuration |
| 36 | +├── node/ # Node system (core data model) |
| 37 | +├── ctl/ # CLI (infrahubctl) |
| 38 | +└── pytest_plugin/ # Custom pytest plugin |
| 39 | +``` |
| 40 | + |
| 41 | +## Markdown Style |
| 42 | + |
| 43 | +When editing `.md` or `.mdx` files, run `uv run invoke lint-docs` before committing. |
| 44 | + |
| 45 | +Key rules: |
| 46 | + |
| 47 | +- Use `text` language for directory structure code blocks |
| 48 | +- Add blank lines before and after lists |
| 49 | +- Always specify language in fenced code blocks (`python`, `bash`, `text`) |
| 50 | + |
| 51 | +## Boundaries |
| 52 | + |
| 53 | +✅ **Always** |
| 54 | + |
| 55 | +- Run `uv run invoke format lint` before committing Python code |
| 56 | +- Run markdownlint before committing markdown changes |
| 57 | +- Follow async/sync dual pattern for new features |
| 58 | +- Use type hints on all function signatures |
| 59 | + |
| 60 | +⚠️ **Ask first** |
| 61 | + |
| 62 | +- Adding new dependencies |
| 63 | +- Changing public API signatures |
| 64 | + |
| 65 | +🚫 **Never** |
| 66 | + |
| 67 | +- Push to GitHub automatically (always wait for user approval) |
| 68 | +- Mix async/sync inappropriately |
| 69 | +- Modify generated code (protocols.py) |
| 70 | +- Bypass type checking without justification |
| 71 | + |
| 72 | +## Subdirectory Guides |
| 73 | + |
| 74 | +- [docs/AGENTS.md](docs/AGENTS.md) - Documentation (Docusaurus) |
| 75 | +- [infrahub_sdk/ctl/AGENTS.md](infrahub_sdk/ctl/AGENTS.md) - CLI development |
| 76 | +- [infrahub_sdk/pytest_plugin/AGENTS.md](infrahub_sdk/pytest_plugin/AGENTS.md) - Pytest plugin |
| 77 | +- [tests/AGENTS.md](tests/AGENTS.md) - Testing |
0 commit comments