Guidance for Claude Code working with this repository.
uv sync --all-extras # Install dependencies
uv run pre-commit install # Setup hooks
cp .env.example .env # Add KATANA_API_KEY| Command | Time | When to Use |
|---|---|---|
uv run poe quick-check |
~5-10s | During development |
uv run poe agent-check |
~8-12s | Before committing |
uv run poe check |
~30s | Before opening PR |
uv run poe full-check |
~40s | Before requesting review |
uv run poe fix |
~5s | Auto-fix lint issues |
uv run poe test |
~16s | Run tests (4 workers) |
NEVER CANCEL long-running commands - they may appear to hang but are processing.
FIX ALL ISSUES. NO EXCEPTIONS.
- NO
noqa,type: ignore, exclusions, or skips - NO "pre-existing issues" or "unrelated to my changes" excuses
- NO
--no-verifycommits - ASK for help if blocked - don't work around errors
Proper fixes:
- Too many parameters? → Create a dataclass
- Name shadows built-in? → Rename it
- Circular import? → Use
TYPE_CHECKINGblock
Always run the appropriate validation tier before considering work complete. See the
Essential Commands table above - use quick-check during development, agent-check
before committing, and check before opening a PR. Don't trust that code works just
because it looks right.
This file is meant to evolve. Update it when you learn something that would help future sessions:
- Fix a tricky bug? Add the root cause to Known Pitfalls.
- Discover a new anti-pattern? Add it to Anti-Patterns to Avoid.
- Find a command or workflow that's missing? Add it to Essential Commands or Detailed Documentation.
- Hit a confusing API behavior? Document it so the next session doesn't waste time rediscovering it.
The same applies to all project documentation - if instructions are wrong, incomplete, or misleading, fix them as part of your current work rather than leaving them for later.
This is a living document. When you discover a new recurring mistake, surprising API behavior, or gotcha during development, add it here so future sessions don't repeat it.
Common mistakes to avoid:
- Editing generated files -
api/**/*.py,models/**/*.py, andclient.pyare generated. Runuv run poe regenerate-clientinstead of editing them directly. - Forgetting pydantic regeneration - After
uv run poe regenerate-client, always runuv run poe generate-pydantictoo. They must stay in sync. - UNSET vs None confusion - attrs model fields that are unset use a sentinel value,
not
None. Useunwrap_unset(field, default)fromkatana_public_api_client.domain.converters, notisinstanceorhasattrchecks. - Manual status code checks - Don't write
if response.status_code == 200. Useunwrap_as(),unwrap_data(), oris_success()fromkatana_public_api_client.utils. - Wrapping API methods for retries - Resilience (retries, rate limiting) is at the
transport layer. All 100+ endpoints get it automatically via
KatanaClient. - Raw list responses in tests - Katana wraps ALL list responses in
{"data": [...]}. Never define raw arrays in mocks.
Monorepo with 3 packages:
katana_public_api_client/- Python client with transport-layer resiliencekatana_mcp_server/- MCP server for AI assistantspackages/katana-client/- TypeScript client
Key pattern: Resilience (retries, rate limiting, pagination) is implemented at the httpx transport layer - ALL 100+ API endpoints get it automatically.
| Category | Files | Action |
|---|---|---|
| EDITABLE | katana_client.py, tests/, scripts/, docs/ |
Can modify |
| GENERATED | api/**/*.py, models/**/*.py, client.py |
DO NOT EDIT |
Regenerate client: uv run poe regenerate-client (2+ min)
feat(client): add feature # Client MINOR release
fix(mcp): fix bug # MCP PATCH release
docs: update README # No releaseUse ! for breaking changes: feat(client)!: breaking change
Use the helper utilities in katana_public_api_client/utils.py for consistent response
handling:
from katana_public_api_client.utils import unwrap, unwrap_as, unwrap_data, is_success
from katana_public_api_client.domain.converters import unwrap_unset
# For single-object responses (200 OK with parsed model)
order = unwrap_as(response, ManufacturingOrder) # Type-safe with validation
# For list responses (200 OK with data array)
items = unwrap_data(response, default=[]) # Extracts .data field
# For success-only responses (201 Created, 204 No Content)
if is_success(response):
# Handle success case
# For attrs model fields that may be UNSET
status = unwrap_unset(order.status, None) # Returns None if UNSET| Scenario | Pattern | Example |
|---|---|---|
| Single object (200) | unwrap_as(response, Type) |
Get/update operations |
| List endpoint (200) | unwrap_data(response, default=[]) |
List operations |
| Create (201) | is_success(response) |
POST with no body |
| Delete/action (204) | is_success(response) |
DELETE, fulfill |
| attrs UNSET field | unwrap_unset(field, default) |
Optional API fields |
# ❌ DON'T: Manual status code checks
if response.status_code == 200:
result = response.parsed
# ✅ DO: Use helpers
result = unwrap_as(response, ExpectedType)
# ❌ DON'T: isinstance with UNSET
if not isinstance(value, type(UNSET)):
use(value)
# ✅ DO: Use unwrap_unset
use(unwrap_unset(value, default))
# ❌ DON'T: hasattr for attrs-defined fields
if hasattr(order, "status"):
status = order.status
# ✅ DO: Use unwrap_unset (attrs fields always exist, may be UNSET)
status = unwrap_unset(order.status, None)unwrap() and unwrap_as() raise typed exceptions:
AuthenticationError- 401 UnauthorizedValidationError- 422 Unprocessable EntityRateLimitError- 429 Too Many RequestsServerError- 5xx server errorsAPIError- Other errors (400, 403, 404, etc.)
Project slash commands available in .claude/commands/:
| Command | Purpose |
|---|---|
/techdebt |
Scan for tech debt and anti-patterns |
/review |
Structured code review of current branch |
/write-tests |
Write comprehensive tests for target code |
/generate-docs |
Generate or update documentation |
/verify |
Skeptically validate implementation quality |
Discover on-demand - read these when working on specific areas:
| Topic | File |
|---|---|
| Agent workflows | AGENT_WORKFLOW.md |
| Validation tiers | .github/agents/guides/shared/VALIDATION_TIERS.md |
| Commit standards | .github/agents/guides/shared/COMMIT_STANDARDS.md |
| File organization | .github/agents/guides/shared/FILE_ORGANIZATION.md |
| Architecture | .github/agents/guides/shared/ARCHITECTURE_QUICK_REF.md |
| Client guide | katana_public_api_client/docs/guide.md |
| MCP docs | katana_mcp_server/docs/README.md |
| TypeScript client | packages/katana-client/README.md |
| ADRs | docs/adr/README.md |