AI agents

Grant research agent with cited sources and outlines

Python agent that finds open grants for a nonprofit, extracts deadlines and eligibility, and drafts a cited application outline in the funder's format.

pythonanthropicpydantichttpxpytestuv

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 grant-research-agent-with-cited-sources-and-outlines-c487c3
11 filesDownload zip
CLAUDE.md
# the app

the app is a Python agent that takes a nonprofit's mission and budget and returns ranked grant matches plus a cited application outline in the funder's format. Every deadline, amount, and eligibility claim must trace to a fetched source page.

@REVIEW.md

## Stack

- Python 3.12, managed with uv
- pydantic v2 models
- httpx for fetching
- Anthropic SDK for structured extraction and drafting
- pytest, ruff, mypy

## Commands

- Install: `uv sync`
- Tests: `uv run pytest -q`
- Lint and format check: `uv run ruff check . && uv run ruff format --check .`
- Types: `uv run mypy src`
- Live run: `uv run python -m the app run --profile examples/profile.json`
- Offline run: `uv run python -m the app run --profile examples/profile.json --offline`
- Citation check: `uv run python -m the app check-citations out/report.json`

## Layout

- `src/the app/profile.py`: organization profile loading and validation
- `src/the app/search/`: Source interface and implementations
- `src/the app/extract.py`: structured extraction of deadline, amount, eligibility
- `src/the app/match.py`: eligibility, budget fit, mission scoring, expiry filter
- `src/the app/outline.py`: ApplicationOutline drafting
- `src/the app/cite.py`: Citation model and citation checks
- `src/the app/cli.py`: `run` and `check-citations` entry points
- `tests/`: pytest suite, uses fake LLM client
- `fixtures/`: saved grant pages and golden JSON, do not edit goldens without asking
- `examples/`: sample profiles

## Citation rules

- Every claim about a deadline, amount, or eligibility rule carries a Citation: url, retrieved_at, quoted snippet.
- No citation means the field is null and flagged `unverified`. Never guess.
- Never invent grants. Only report grants found in fetched pages.
- Quoted snippets must appear in the cached source text.
- Store deadlines as ISO dates with timezone when the page states one. Flag ambiguous dates for human review.
- Outlines follow the funder's section headings and word limits when given. Requirements not found in the guidelines go under "Needs confirmation".

## Fetching and secrets

- Respect robots.txt. Rate limit to 1 request per second per host.
- Cache fetched HTML under `.cache/`. It is gitignored and must never be committed.
- Live runs need `ANTHROPIC_API_KEY` from the environment. Never write keys to files or logs.
- Tests make no network or API calls. Use saved fixtures and the fake LLM client.

## Gotchas

- Funder pages change. Golden tests on fixtures will not catch live drift; use the live smoke run in Phase 5.
- Expired grants are excluded by comparing extracted deadlines to today's date in UTC-aware time.
- The `/goal` evaluator is a small fast model that sees only the conversation. Show command output in the conversation.

## Workflow

- Explore, then plan, then code, then run the verify skill before saying a task is done.
- Work phase by phase from PLAN.md. Run `/clear` and commit between phases, asking before each commit.
- Do not add dependencies beyond httpx, pydantic, anthropic, pytest, ruff, mypy without asking.
- Keep modules under 200 lines.

## Models and subagents

- Default model for main work. Effort stays at the default unless a step needs more.
- Use `ultrathink` only for outline structure design.
- `source-reader` (Haiku) reads long saved pages and returns quoted facts.
- `test-runner` (Haiku) runs the suite and returns only failures.
- Use `/effort` mid-task rather than switching models, to keep the prompt cache.
Use for my project