AI agents

Real estate listing writer with fair housing checker

Python AI assistant that turns bullets and photos into listings in three tones and flags fair housing issues before publishing.

pythonfastapipydanticanthropicpytestuv

Built 1 time, downloaded 0 times.

Install from your terminal

Run this in your project folder. It signs you in, shows what changes and asks before it overwrites a file.

npx claude-lab add real-estate-listing-writer-with-fair-housing-checker-fd9ee5
10 filesDownload zip
CLAUDE.md
# Real estate listing writer

## Purpose

Agents give bullets and photos. The app returns three listing drafts (professional, warm, punchy). Each draft gets a fair housing check before it can be published. The check has a deterministic layer and an LLM review layer. The checker is advisory support, not legal advice.

## Stack

- Python 3.12, FastAPI, Pydantic v2
- Anthropic Python SDK
- pytest, ruff, mypy
- uv for dependencies

## Layout

- `src/listings/api.py`: FastAPI app
- `src/listings/generator.py`: bullets to three tones
- `src/listings/vision.py`: photo resize and captions
- `src/listings/fairhousing/rules.py` and `checker.py`: rule checks
- `src/listings/prompts/`: tone prompt files
- `data/rules/fair_housing_terms.yaml`: term and pattern list
- `tests/`, `tests/fixtures/` (sample bullets, small sample photos)

## Commands

- `uv sync`
- `uv run pytest -q`
- `uv run ruff check .`
- `uv run ruff format .`
- `uv run mypy src`
- `uv run uvicorn listings.api:app --reload`
- `uv run python -m listings.cli sample`

## Rules

- A listing is never publishable unless the fair housing check ran on the exact final text. Any edit invalidates the prior check.
- Checking runs in two layers. First, deterministic terms and patterns for protected classes: race, color, religion, sex, disability, familial status, national origin, plus state extras. Then an LLM contextual review that returns structured JSON. Either layer failing blocks publish.
- Output and UI must say the checker is not legal advice. Never claim a listing is compliant. Only say no issues were found.
- Describe the property, not the people. No steering language such as "perfect for young families" or "walking distance to church". The word "master" is flagged for review per the rules file.
- Only describe what is in the bullets or visible in photos. Never invent square footage, school ratings, or neighborhood demographics.

## Models and secrets

- Model names live in `config.py` only, never in prompts.
- Use the small model for the LLM compliance pass and photo captions. Use the default model for writing.
- `ANTHROPIC_API_KEY` comes from the environment or `.env`. `.env` is gitignored.
- `.env.example` uses `YOUR_API_KEY`.
- Never log photo contents or agent client names.

## Gotchas

- Resize images to 1568px on the long edge, then send them as base64.
- Validate structured output with Pydantic. Retry once on parse failure, then fail loudly.

## Testing

- Unit tests mock LLM calls with recorded fixtures.
- Real API calls are not allowed in tests.
- One optional live test is marked `@pytest.mark.live` and is skipped by default.

## Conventions

- Type hints everywhere.
- Pure functions for rules. No global state.
- Small modules.

## Workflow

- Explore, plan, code, then run the verify skill before saying done.
- Use `/clear` between unrelated tasks.

@REVIEW.md
Use for my project