AutoRAG-Research
CLAUDE.md149 starsChanged 8 months agoApache-2.0View on GitHub
AutoRAG-Research is a Python framework for automating RAG (Retrieval-Augmented Generation) research workflows. It provides tools for data ingestion, pipeline execution, and evaluation metrics. The user can download pre-ingested datasets and run pre-made RAG pipelines and evaluate it. The pipelines can be customized. There are two types (retrieval/generation) pipelines. The codebase follows a layered architecture with Generic Repository + Unit of Work + Service Layer patterns: Pipeline Types: - Retrieval Pipelines (pipelines/retrieval/) - Vector search, BM25, hybrid retrieval - Extend BaseRetrievalPipeline…
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .codex/AGENTS.mdAGENTS.md
- autorag-querySkill
- create-generation-pluginSkill
- create-ingestor-pluginSkill
- create-metric-pluginSkill
- create-retrieval-pluginSkill
- refactorSkill
- resolve-conversationSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
15 rules. About 0 are common, 4 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 80
Async: Use SQLAlchemy's greenlet-based bridging (sqlalchemy.util.concurrency.greenlet_spawn)
- Very specific: line 84
Use db_session fixture from conftest.py (don't create new sessions)
- Very specific: line 85
Test data is pre-seeded in postgresql/db/init/002-seed.sql - use it
- Very specific: line 86
Test file structure mirrors package structure in tests/
- Distinctive: line 98
Prefer mocks over real API calls (use LangChain FakeListLLM/FakeEmbeddings from langchain_core).
- Distinctive: line 109
Do not use print statements for logging.
- Very specific: line 113
MANDATORY: Before implementing any utility logic, consult ai_instructions/utility_reference.md.
- Very specific: line 114
DO NOT duplicate — reuse existing helpers.
- Distinctive: line 119
Query: - Search queries with ground truth
- Distinctive: line 140
Do not use relative imports.
- Very specific: line 141
Always use uv sync --all-extras --all-groups to install dependencies to avoid missing optional packages.
- Very specific: line 142
Do not add __init__.py in tests/ directory.
- Very specific: line 143
DO NOT CHANGE ty, ruff, deptry configurations in the pyproject.toml.
- Very specific: line 144
DO NOT USE global variable anywhere in the codebase.
- Very specific: line 145
When adding new utility functions to util.py, you MUST also update ai_instructions/utility_reference.md.
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Project Overview
AutoRAG-Research is a Python framework for automating RAG (Retrieval-Augmented Generation) research workflows. It provides tools for data ingestion, pipeline execution, and evaluation metrics. The user can download pre-ingested datasets and run pre-made RAG pipelines and evaluate it. The pipelines can be customized. There are two types (retrieval/generation) pipelines.
Common Commands
# Setup
make install # Create venv, install deps, setup pre-commit hooks
uv sync --all-groups --all-extras # Install all deps including optional (gpu, search)
# Code Quality
make check # Run all checks (ruff, ty type checker, deptry)
# Testing (requires Docker)
make test # Full test with Docker PostgreSQL lifecycle management
make test-only # Run tests (assumes PostgreSQL container is running)
make test-data # Run tests only marked as data
make test-full # Run all tests including api/gpu/data marked tests
# Run single test
uv run pytest tests/path/to/test_file.py::test_function_name -v
# Docker
make docker-up # Start PostgreSQL container
make docker-wait # Wait for PostgreSQL readiness
make docker-down # Stop container
make clean-docker # Remove container and volumes
# Docs
make docs # Build and serve docs locallyArchitecture
The codebase follows a layered architecture with Generic Repository + Unit of Work + Service Layer patterns:
Executor/Evaluator (config.py, executor.py, evaluator.py)
↓
Pipeline Layer (pipelines/)
↓
Service Layer (orm/service/) - Business logic
↓
Unit of Work (orm/uow/) - Transaction management
↓
Repository Layer (orm/repository/) - Data access (GenericRepository[T])
↓
ORM Models (orm/models/) - SQLAlchemy with pgvectorPipeline Types:
- Retrieval Pipelines (
pipelines/retrieval/) - Vector search, BM25, hybrid retrieval- Extend
BaseRetrievalPipeline - Use
RetrievalPipelineService+RetrievalUnitOfWork - Methods:
.retrieve(query, top_k)for single-query,.run()for batch
- Extend
- Generation Pipelines (
pipelines/generation/) - LLM-based answer generation- Extend
BaseGenerationPipeline - Use
GenerationPipelineService+GenerationUnitOfWork - Compose with retrieval pipelines for flexible RAG strategies
- Example:
NaiveRAGPipeline(single retrieve + generate)
- Extend
Key Entry Points:
executor.py- Orchestrates pipeline execution and metric evaluationconfig.py- Configuration dataclasses (ExecutorConfig, BasePipelineConfig, BaseMetricConfig)orm/schema_factory.py- Dynamic schema creation with custom embedding dimensions viacreate_schema(dim)
Database Patterns
- Generic Repository: Base CRUD in
orm/repository/base.py, specialized repos extend it - Unit of Work: Context managers in
orm/uow/ensure transaction safety - Service Layer: Business logic in
orm/service/, uses UoW for data access - Vector Search: Uses VectorChord with pgvector
Vectortype - Driver: psycopg3 (imported as
psycopg) - Async: Use SQLAlchemy's greenlet-based bridging (
sqlalchemy.util.concurrency.greenlet_spawn)
Testing Guidelines
- Use
db_sessionfixture from conftest.py (don't create new sessions) - Test data is pre-seeded in
postgresql/db/init/002-seed.sql- use it - Test file structure mirrors package structure in
tests/ - One test function = one function under test
- Clean up any data you add in tests
Test Markers:
@pytest.mark.gpu # Requires GPU
@pytest.mark.api # Requires LLM/API calls (prefer mocks)
@pytest.mark.data # Downloads external data
@pytest.mark.asyncio # Async testPrefer mocks over real API calls (use LangChain FakeListLLM/FakeEmbeddings from langchain_core).
Code Style
- Python 3.10+ type hints: use
list,dict,|(nottyping.List,typing.Optional) - Line length: 120 characters
- Ruff for linting/formatting
- Type checking: ty
Logging
- Alwasy use
logger = logging.getLogger("AutoRAG-Research")to initialize logger - Do not use print statements for logging. Or any other logging methods.
Utility Functions (DRY!)
MANDATORY: Before implementing any utility logic, consult ai_instructions/utility_reference.md.
DO NOT duplicate — reuse existing helpers. Run /check-duplication to verify.
Key Database Tables
- Document/Page/Chunk/ImageChunk - Content storage with embeddings
- Query - Search queries with ground truth
- RetrievalRelation - Query-to-chunk relevance (composite key: query_id, group_index, group_order)
- Pipeline/Metric - Configuration storage
- ChunkRetrievedResult - Retrieval pipeline outputs (query → chunks with scores)
- ExecutorResult - Generation pipeline outputs (generation_result, token_usage, execution_time)
- EvaluationResult - Metric evaluation outputs
AI Instructions
Detailed patterns and examples are in /ai_instructions/ (and schema DDL in postgresql/db/init/):
db_pattern.md- Repository, UoW, Service patterns with code examplespostgresql/db/init/001-schema.sql- Canonical DB schema DDL (single source of truth)test_code_generation_instructions.md- Testing conventionsutility_reference.md- MANDATORY utility & service method catalog (read before implementing)pipeline_checklist.md- MANDATORY pipeline completion checklist (verify before merging any pipeline PR)metric_implementation.md- MANDATORY checklist for adding new evaluation metrics (Config, YAML, exports, tests)
Strict Rules to follow
- Code quality checks are automated via hooks -
make checkruns automatically after file edits and on session end - Generate the corresponding test file correctly when you add the code, and runs the test code before commit (
make test) - Do not use relative imports.
- Always use
uv sync --all-extras --all-groupsto install dependencies to avoid missing optional packages. - Do not add
__init__.pyintests/directory. - DO NOT CHANGE ty, ruff, deptry configurations in the
pyproject.toml. Use ignore annotation if necessary. - DO NOT USE
globalvariable anywhere in the codebase. - When adding new utility functions to
util.py, you MUST also updateai_instructions/utility_reference.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

