Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Adaptation Atlas Co-Pilot - A climate adaptation AI assistant with two main components:
The system uses Mistral AI models for chat and code generation, with both a Chainlit interface for development and a React frontend for production use.
# Initial setup git clone [email protected]:AdaptationAtlas/adaptation-atlas-assistant.git cd adaptation-atlas-assistant uv sync uv run prek install # Configure environment cp .env.example .env # Add MISTRAL_API_KEY and set CHAT_MODEL_SIZE (large/medium/small) # Initialize dataset embeddings (required before first run) uv run python scripts/embed_datasets.py # Run the Chainlit UI (for development) uv run chainlit run chainlit/app.py -w
# Navigate to frontend directory cd frontend # Install dependencies npm install # Start development server npm run dev # Runs on http://localhost:5173 # Build for production npm run build
Work is tracked on the project board.
# Run all tests (unit tests only) uv run pytest # Run tests including agent integration tests (requires LLM access) uv run pytest --agent # Run linters and formatters uv run prek run --all-files # Activate virtual environment (to skip 'uv run' prefix) source .venv/bin/activate # Run Chainlit development server uv run chainlit run chainlit/app.py -w
# Development server with hot reload npm run dev # http://localhost:5173 # Production build npm run build # Output to frontend// # Preview production build npm run preview # Run linter npm run lint
# Run a single test file uv run pytest tests/test_agent.py # Run tests matching a pattern uv run pytest -k "test_name_pattern" # Run with verbose output uv run pytest -v # Run specific test markers uv run pytest -m agent # Same as --integration flag
The React frontend provides a modern web interface with:
See frontend/CLAUDE.md for detailed frontend documentation.
The backend uses LangGraph's
create_react_agent with a custom state schema and two primary tools:
data/datasets.jsonAgent Flow:
User Query → Agent (Mistral chat model) → Tool Selection ↓ select_dataset (ChromaDB similarity search) ↓ create_chart (Codestral generates SQL → DuckDB execution → Codestral generates Plotly code) ↓ Visualization + Response
Backend state via custom
AgentState (extends AgentStatePydantic):
dataset: Selected dataset metadata from ChromaDBchart_query: Generated SQL query for data extractionpython_code: Generated Plotly visualization codechart_data: Processed data for visualizationchart: Final Plotly chart JSONState is persisted via
InMemorySaver checkpointer with thread-based conversation history.
# Backend Structure src/atlas_assistant/ ├── agent.py # LangGraph agent creation and system prompt ├── state.py # AgentState schema definition ├── settings.py # Pydantic settings with Mistral API config └── tools/ ├── select_dataset.py # ChromaDB-based dataset retrieval └── create_chart.py # SQL generation + Plotly visualization # Frontend Structure frontend/ ├── src/ │ ├── components/ # React components │ │ ├── PromptBox/ # Input component with context tags │ │ └── Welcome/ # Main application layout │ ├── assets/ │ │ └── icons.tsx # Icon components │ ├── App.tsx # Root component │ ├── main.tsx # Application entry point │ └── index.css # Global styles and design tokens ├── package.json # Frontend dependencies ├── vite.config.ts # Vite configuration ├── tsconfig.json # TypeScript configuration └── CLAUDE.md # Frontend-specific documentation # Root Level app.py # Chainlit UI handlers (@cl.on_chat_start, @cl.on_message) scripts/ ├── embed_datasets.py # Creates ChromaDB embeddings from datasets.json └── parquet_analyzer.py # Utility for analyzing parquet files data/ ├── datasets.json # Dataset metadata (name, info, S3 path, etc.) └── atlas-assistant-docs-mistral-index/ # ChromaDB vector store (created by embed_datasets.py) .chainlit/ # Chainlit UI configuration docs/decisions/ # Architectural Decision Records (ADRs)
Tool Execution:
Command objects to update agent stateselect_dataset: Performs similarity search (k=3), returns top matchcreate_chart: Two-stage LLM process:
Data Access:
s3://digital-atlas/...)data/datasets.json with metadata:
key: Unique identifier for the datasetactive: Whether the dataset is available for useinfo: Short description for dataset discoverynote: Detailed context about the dataset (scenarios, variables, usage)s3: S3 path to the parquet filename: Table name for SQL queriesinfo and note fields for semantic search during select_datasetModel Configuration:
mistral-{size}-latest (configurable via CHAT_MODEL_SIZE)codestral-latest (hardcoded)mistral-embed (hardcoded)pytest markers:
@pytest.mark.agent: Integration tests requiring --integration flag (uses actual Mistral API)Fixtures (tests/conftest.py):
settings: Returns configured Settings objectrun_agent: Async function to invoke agent with a query stringuv run python scripts/embed_datasets.py to rebuild embeddingssrc/atlas_assistant/agent.pysrc/atlas_assistant/tools/, register in agent.py tools listapp.py (@cl.on_chat_start, @cl.on_message)frontend/src/components/ with corresponding CSS modulesindex.css or component-specific .module.css filesfrontend/src/assets/icons.tsxPlanned integration points:
pyproject.toml)sync-with-uv: Ensures uv.lock is up to dateruff-check: Auto-fixes lint issuesruff-format: Formats code.github/workflows/ci.yaml)Architectural Decision Records (ADRs) are maintained in
docs/decisions/ using the MADR format. When making significant architectural changes:
docs/decisions/0001-my-decision.md)Required in
.env:
MISTRAL_API_KEY: API key for Mistral AICHAT_MODEL_SIZE: "large", "medium", or "small" (default: "small")Optional:
CHAT_MODEL_TEMPERATURE: Float, default 0.0 (deterministic responses)"Database does not exist" error: Run
uv run python scripts/embed_datasets.py to create ChromaDB index
Import errors: Ensure you've run
uv sync and activated the environment
Agent test failures: Verify
MISTRAL_API_KEY is set in .env before running pytest --agent
Chainlit not starting: Check port 8000 is not in use, try
uv run chainlit run chainlit/app.py -w --port 8001
Module not found: Run
npm install in the frontend directory
Port already in use: Vite dev server defaults to 5173, change with
npm run dev -- --port 3000
TypeScript errors: Run
npm run build to see all type errors, fix before committing
CSS modules not working: Ensure files are named
*.module.css and imported correctly