|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Microsoft Teams Python SDK — a UV workspace with multiple packages providing APIs, common utilities, and integrations for Microsoft Teams. |
| 8 | + |
| 9 | +## Development Setup |
| 10 | + |
| 11 | +### Prerequisites |
| 12 | +- UV >= 0.8.11 |
| 13 | +- Python >= 3.12 |
| 14 | + |
| 15 | +### Commands |
| 16 | +```bash |
| 17 | +uv sync # Install virtual env and dependencies |
| 18 | +source .venv/bin/activate # Activate virtual environment |
| 19 | +pre-commit install # Install pre-commit hooks |
| 20 | + |
| 21 | +poe fmt # Format code with ruff |
| 22 | +poe lint # Lint code with ruff |
| 23 | +poe check # Run both format and lint |
| 24 | +poe test # Run tests with pytest |
| 25 | +pyright # Run type checker |
| 26 | +``` |
| 27 | + |
| 28 | +## Tooling |
| 29 | + |
| 30 | +- **Formatter/Linter**: Ruff — line length 120, rules: E, F, W, B, Q, I, ASYNC |
| 31 | +- **Type checker**: Pyright |
| 32 | +- **Test framework**: pytest + pytest-asyncio (Ruff bans importing the unittest test framework; unittest.mock is allowed and used) |
| 33 | + |
| 34 | +## Architecture |
| 35 | + |
| 36 | +### Workspace Structure |
| 37 | +All packages live in `packages/`, each with `src/microsoft_teams/<package>/` layout: |
| 38 | + |
| 39 | +| Package | Description | |
| 40 | +|---------|-------------| |
| 41 | +| `api` | Core API clients, models (Account, Activity, Conversation), auth | |
| 42 | +| `apps` | App orchestrator, plugins, routing, events, HttpServer | |
| 43 | +| `common` | HTTP client abstraction, logging, storage | |
| 44 | +| `cards` | Adaptive cards | |
| 45 | +| `ai` | AI/function calling utilities | |
| 46 | +| `botbuilder` | Bot Framework integration plugin | |
| 47 | +| `devtools` | Development tools plugin | |
| 48 | +| `mcpplugin` | MCP server plugin | |
| 49 | +| `a2aprotocol` | A2A protocol plugin | |
| 50 | +| `graph` | Microsoft Graph integration | |
| 51 | +| `openai` | OpenAI integration | |
| 52 | + |
| 53 | +### Key Patterns |
| 54 | + |
| 55 | +**Imports** |
| 56 | +- ALL imports MUST be at the top of the file — no imports inside functions, classes, or conditional blocks |
| 57 | +- Avoid `TYPE_CHECKING` blocks unless absolutely necessary (genuine circular imports that can't be restructured) |
| 58 | +- Avoid dynamic/deferred imports unless absolutely necessary |
| 59 | +- Relative imports within the same package, absolute for external packages |
| 60 | + |
| 61 | +**Models** |
| 62 | +- Pydantic with `ConfigDict(alias_generator=to_camel)` — snake_case in Python, camelCase in JSON |
| 63 | +- `model_dump(by_alias=True)` for serialization, `model_dump(exclude_none=True)` for query params |
| 64 | + |
| 65 | +**Interfaces** |
| 66 | +- Protocol classes instead of Abstract Base Classes (ABC) |
| 67 | +- Prefer composition over inheritance |
| 68 | + |
| 69 | +**Clients** |
| 70 | +- Concrete clients inherit from `BaseClient` (`packages/api/src/microsoft_teams/api/clients/base_client.py`) |
| 71 | +- Composition with operation classes for sub-functionality |
| 72 | +- async/await for all API calls, return domain models |
| 73 | + |
| 74 | +## Scaffolding (cookiecutter) |
| 75 | + |
| 76 | +```bash |
| 77 | +cookiecutter templates/package -o packages # New package |
| 78 | +cookiecutter templates/test -o tests # New test package |
| 79 | +``` |
| 80 | + |
| 81 | +## Dependencies and Build |
| 82 | + |
| 83 | +- UV workspace — packages reference each other via `{ workspace = true }` |
| 84 | +- Hatchling build backend |
| 85 | +- Dev dependencies in root `pyproject.toml` |
0 commit comments