Contributing
RAG Doctor is open source and actively maintained. Contributions are welcome and encouraged — whether that means fixing a bug, improving documentation, writing a new rule, or building an adapter for a trace format we don't yet support.
Before you start
Getting started
Clone the repository
git clone https://github.com/rag-doctor/rag-doctor.gitcd rag-doctorInstall dependencies
# Install all workspace dependenciesnpm install # Or with pnpm (recommended for monorepo)pnpm installBuild all packages
npm run build # Or build a specific packagenpm run build --workspace=packages/rulesRun the test suite
# Run all testsnpm test # Run tests in watch modenpm run test:watch # Run tests for a specific packagenpm test --workspace=packages/rulesProject structure
rag-doctor/├── packages/│ ├── types/ # @rag-doctor/types│ ├── ingestion/ # @rag-doctor/ingestion│ ├── rules/ # @rag-doctor/rules│ ├── core/ # @rag-doctor/core│ ├── diagnostics/ # @rag-doctor/diagnostics│ └── reporters/ # @rag-doctor/reporters├── apps/│ └── cli/ # rag-doctor CLI├── docs/ # Documentation site├── examples/ # Usage examples└── package.json # Root workspace configWhere to contribute
Adding a new rule
New rules go in packages/rules/src/rules/. Each rule is a single TypeScript file that exports a rule definition object:
1// packages/rules/src/rules/my-new-rule.ts2import type { Rule } from "@rag-doctor/types";3 4export const myNewRule: Rule = {5 id: "my-new-rule",6 name: "My New Rule",7 description: "Detects something specific about the trace",8 defaultSeverity: "warning",9 defaultOptions: {10 threshold: 0.5,11 },12 evaluate(ctx, options) {13 const findings = [];14 // ... rule logic15 return findings;16 },17};Then register it in packages/rules/src/index.ts and add it to the appropriate rule packs in packages/rules/src/packs/. Add tests in packages/rules/src/__tests__/.
Improving diagnostics
The heuristic graph lives in packages/diagnostics/src/graph.ts. You can add new cause entries, improve recommendation text, or adjust priority weights. All changes must include unit tests.
Adding a trace adapter
Adapters convert third-party trace formats to RAG Doctor's normalized trace shape. Add adapters to packages/ingestion/src/adapters/:
1// packages/ingestion/src/adapters/langsmith.ts2import type { RagTrace } from "@rag-doctor/types";3import type { LangSmithRun } from "./langsmith-types";4 5export function fromLangSmith(run: LangSmithRun): RagTrace {6 return {7 query: run.inputs.question,8 chunks: run.outputs.documents.map((doc, i) => ({9 id: doc.metadata.id ?? `chunk-${i}`,10 content: doc.pageContent,11 score: doc.metadata.score ?? 0,12 tokens: doc.metadata.tokenCount ?? 0,13 source: doc.metadata.source,14 })),15 model: run.extra?.modelName,16 totalTokens: run.extra?.totalTokens,17 };18}Improving documentation
Documentation lives alongside the code in the docs/ directory. We especially welcome:
- Real-world examples and use cases
- Integration guides for specific frameworks
- Corrections and clarifications to existing docs
- Translations
Code standards
- All code is TypeScript with strict mode enabled
- Tests are required for all rule changes and new features
- Follow the existing naming conventions in each package
- Run
npm run lintbefore submitting a pull request - Add a changeset entry for user-facing changes
Thank you