Project-wide instructions for Claude Code (claude.ai/code) when working with the Kasal codebase.
Claude reads context from multiple CLAUDE.md files. The closest one to the file you are editing wins on specifics:
- This file: Project-wide patterns and rules
- src/backend/CLAUDE.md: Backend-specific instructions
- src/frontend/CLAUDE.md: Frontend-specific instructions
- Per-layer files (added for precision):
src/backend/src/api/CLAUDE.md— FastAPI routerssrc/backend/src/services/CLAUDE.md— business logicsrc/backend/src/repositories/CLAUDE.md— data accesssrc/backend/src/models/CLAUDE.md— SQLAlchemy models + migrationssrc/backend/src/engines/crewai/CLAUDE.md— the CrewAI engine (post-refactor)src/backend/src/engines/crewai/tools/CLAUDE.md— custom toolssrc/frontend/src/api/CLAUDE.md— frontend service layersrc/frontend/src/components/CLAUDE.md— React componentssrc/frontend/src/shared/a2ui/CLAUDE.md— the A2UI generative-UI system (renderer + composer + catalog + UIConfigurator + exported-app vendoring). Read before adding/editing an A2UI component — the touchpoints span frontend, backend and the export template.
- Python dependencies are managed with
uv— declared insrc/backend/pyproject.tomland pinned insrc/backend/uv.lock(both committed). There is norequirements.txt. - Install dependencies:
cd src/backend && uv sync - To change a dependency: edit
pyproject.toml, runuv lock(regeneratesuv.lock), thenuv sync. Never hand-edituv.lock. - The Databricks App deploy (
src/deploy.py) shipspyproject.toml+uv.lockat the bundle root so the build runsuv sync(arequirements.txtat the root would take precedence and bypass uv). - Key dependencies include: psutil (for process management), crewai, litellm, databricks-sdk
- ALWAYS create documentation in
src/docs/directory - Do not create docs in the root
docs/folder - Frontend copies from
src/docs/topublic/docs/for display - Follow existing documentation patterns and naming conventions
- ALWAYS create test scripts and temporary files in
/tmpfolder - Do not create test files in the project directory
- Use paths like
/tmp/test_script.pyfor testing - This keeps the project directory clean
- DO NOT restart backend or frontend services - They are managed externally
- Backend uses
--reloadflag and auto-detects code changes - Frontend uses hot module replacement (HMR) and auto-updates in browser
- Check service status:
ps aux | grep uvicorn(backend) orps aux | grep "npm start"(frontend)
- CRITICAL: All operations must be async and non-blocking
- CRITICAL: Never include real URLs, endpoints, or addresses in code
- Always use placeholder values like "https://example.com" or environment variables
- Follow clean architecture principles
- Never commit without running linting tools
- Build frontend static assets:
python src/build.py - Deploy application:
python src/deploy.py
Kasal is an AI agent workflow orchestration platform with a clean architecture pattern:
Frontend (React + TypeScript) → API (FastAPI) → Services → Repositories → Database
- Backend: FastAPI + SQLAlchemy 2.0 (async) + Alembic (Python 3.11, pinned
>=3.11,<3.12) - Frontend: React 18 + TypeScript + Material-UI + ReactFlow, built with Vite
- AI Engine: CrewAI framework for agent orchestration
- Database: SQLite (dev) / PostgreSQL / Databricks Lakebase (prod)
- Authentication: Databricks OAuth (OBO / SPN); JWT for app sessions
src/
├── backend/ # FastAPI backend (see backend/CLAUDE.md)
│ ├── src/ # Core application code
│ ├── tests/ # Unit and integration tests
│ └── migrations/ # Database migrations
├── frontend/ # React frontend (see frontend/CLAUDE.md)
│ └── src/ # React application
└── frontend_static/ # Built frontend assets
- Backend:
cd src/backend && ./run.sh(auto-reloads on changes) - Frontend:
cd src/frontend && npm start(hot module replacement) - Tests: See respective CLAUDE.md files for testing commands
- Clean Architecture: Separation of concerns across layers
- Async-First: All I/O operations must be async
- Type Safety: Strong typing in both backend (mypy) and frontend (TypeScript)
- Test Coverage: Minimum 80% for backend, comprehensive frontend testing
- CrewAI crews generate deterministic IDs for memory persistence
- Group isolation ensures tenant data separation
- Databricks Vector Search integration for advanced memory backends
- Support for multiple LLM providers (Databricks, OpenAI, Anthropic, etc.)
- Model configurations in
src/backend/src/seeds/model_configs.py - Automatic handling of provider-specific requirements
- When searching for Databricks Apps information, always check first: https://apps-cookbook.dev/docs/streamlit/authentication/users_obo
- This reference covers authentication patterns and user on-behalf-of (OBO) flows
For detailed backend instructions, see: src/backend/CLAUDE.md For detailed frontend instructions, see: src/frontend/CLAUDE.md
- always make sure whenever you develop anything you need to stick to service architecture pattern, and unit of work architecture pattern and repository architecture pattern.
This project has a graphify knowledge graph at graphify-out/.
Rules:
- Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
- If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
- For cross-module "how does X relate to Y" questions, prefer
graphify query "<question>",graphify path "<A>" "<B>", orgraphify explain "<concept>"over grep — these traverse the graph's EXTRACTED + INFERRED edges instead of scanning files - After modifying code files in this session, run
graphify update .to keep the graph current (AST-only, no API cost)