Skip to content

Commit b5524c1

Browse files
committed
chore(coderabbit): add custom finishing touch recipes
1 parent f1fc457 commit b5524c1

File tree

1 file changed

+108
-34
lines changed

1 file changed

+108
-34
lines changed

.coderabbit.yaml

Lines changed: 108 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
# https://docs.coderabbit.ai/getting-started/configure-coderabbit
3+
14
# CodeRabbit Configuration
25
# Optimized for Python 3.13 / FastAPI RESTful API project
36

47
language: en-US
58
early_access: true
6-
enable_free_tier: true
79

810
reviews:
911
profile: chill
@@ -23,12 +25,9 @@ reviews:
2325
suggested_labels: true
2426
auto_apply_labels: false
2527
suggested_reviewers: false
26-
auto_assign_reviewers: false
27-
in_progress_fortune: true
2828
poem: false
2929
abort_on_close: true
3030

31-
# Path-based review instructions for this Python/FastAPI project
3231
path_instructions:
3332
- path: "**/*.py"
3433
instructions: |
@@ -96,24 +95,28 @@ reviews:
9695
- path: "**/Dockerfile"
9796
instructions: |
9897
- Verify Python 3.13 base image (python:3.13-alpine)
99-
- Check multi-stage builds for optimization
98+
- Check multi-stage build using pyproject.toml + uv.lock → uv export → wheelhouse
99+
- Ensure runtime stage installs from prebuilt wheels with no network access
100100
- Ensure non-root user is used for security
101101
- Validate HEALTHCHECK instruction is present
102-
- Check that requirements are installed in correct order
103-
104-
- path: "requirements*.txt"
105-
instructions: |
106-
- Verify pinned versions for reproducibility
107-
- Check separation: requirements.txt (runtime), requirements-test.txt, requirements-lint.txt
108-
- Ensure dependencies are up to date with security patches
102+
- Check that uv version is pinned for reproducibility
109103
110104
- path: "pyproject.toml"
111105
instructions: |
112106
- Verify Black configuration (line-length = 88, target-version = ["py313"])
113107
- Check pytest configuration matches test execution
114108
- Ensure tool configurations are consistent with CI
109+
- Dependencies are managed via uv with PEP 735 dependency groups
110+
- Verify [dependency-groups] has test, lint, and dev groups defined
111+
- Check that uv.lock is present and up to date
112+
113+
- path: ".github/workflows/*.yml"
114+
instructions: |
115+
- Verify uv is set up via astral-sh/setup-uv with a pinned version
116+
- Check that dependencies are installed via uv pip install -e . --group dev
117+
- Ensure pytest runs once with combined -v and --cov flags
118+
- Validate coverage report upload step is present
115119
116-
# Ignore patterns for this project
117120
path_filters:
118121
- "!**/__pycache__/**"
119122
- "!**/.pytest_cache/**"
@@ -127,6 +130,7 @@ reviews:
127130
- "!**/*.db-wal"
128131
- "!**/assets/**"
129132
- "!**/postman_collections/**"
133+
- "!**/uv.lock"
130134

131135
auto_review:
132136
enabled: true
@@ -145,55 +149,122 @@ reviews:
145149
enabled: true
146150
unit_tests:
147151
enabled: true
152+
custom:
153+
- name: "sync documentation"
154+
instructions: |
155+
This is a PoC/learning project targeting developers unfamiliar with the stack.
156+
Documentation is a first-class concern. Review the PR changes and perform the
157+
following three checks:
158+
159+
## 1. Method/function docstrings
160+
For every public function, method, or handler touched in the PR:
161+
- If it lacks a docstring/doc comment, add one using the idiomatic format
162+
for the language and framework in use.
163+
- If it has one but no longer matches the current signature, parameters,
164+
or behavior, update it.
165+
- Docstrings should explain *why* and *what*, not just restate the signature.
166+
Assume the reader is learning the language.
167+
168+
## 2. README.md
169+
Check whether the PR introduces or removes endpoints, changes behavior,
170+
adds dependencies, or modifies how to run the project.
171+
If so, update the relevant sections of README.md to reflect the current state.
172+
Do not rewrite sections unrelated to the changes.
173+
174+
## 3. .github/copilot-instructions.md
175+
If the PR introduces patterns, conventions, or architectural decisions that
176+
should guide future AI-assisted contributions, add or update the relevant
177+
instructions in .github/copilot-instructions.md.
178+
Focus on things a developer (or AI assistant) unfamiliar with this specific
179+
stack implementation should know before writing code here.
180+
181+
- name: "enforce http error handling"
182+
instructions: |
183+
Audit all HTTP handler functions in the changed files.
184+
Verify that errors return appropriate HTTP status codes (400 for bad input,
185+
404 for not found, 500 for unexpected errors) and a consistent JSON error
186+
body with at least a "message" field.
187+
Flag handlers that return 200 on error, swallow errors silently, or use
188+
bare status-only responses without a JSON body.
189+
Do not make changes; only report findings as a comment so fixes can be
190+
applied consistently across the entire codebase.
191+
192+
- name: "idiomatic review"
193+
instructions: |
194+
Review the changed files for non-idiomatic patterns given the language and
195+
framework in use. Flag code that looks like it was translated from another
196+
language rather than written naturally for this stack. Suggest idiomatic
197+
alternatives with brief explanations. This is a PoC comparison project,
198+
so idiomatic usage is a first-class concern.
199+
200+
- name: "verify api contract"
201+
instructions: |
202+
Review the changed files and verify that all HTTP endpoints (method, path,
203+
request body shape, and response shape) match the project's intended REST API
204+
contract. Check the README or any spec/contract file in the repo for reference.
205+
Flag any deviations — missing fields, wrong status codes, inconsistent naming.
206+
Do not make changes; only report findings as a comment.
148207
149208
pre_merge_checks:
150209
docstrings:
151210
mode: warning
152-
threshold: 75
211+
threshold: 80
153212
title:
154213
mode: warning
155214
requirements: |
156215
- Use Conventional Commits format (feat:, fix:, chore:, docs:, test:, refactor:)
157216
- Keep under 80 characters
158217
- Be descriptive and specific
159218
description:
160-
mode: warning
219+
mode: off
161220
issue_assessment:
162-
mode: warning
221+
mode: off
163222

164223
tools:
165-
# Relevant tools for Python projects
166-
ruff:
167-
enabled: true
168-
flake8:
169-
enabled: true
170-
pylint:
171-
enabled: true
224+
# Secret scanners
172225
gitleaks:
173226
enabled: true
227+
trufflehog:
228+
enabled: true
229+
230+
# IaC / infrastructure
174231
checkov:
175232
enabled: true
233+
trivy:
234+
enabled: true
176235
hadolint:
177236
enabled: true
237+
238+
# General static analysis
239+
semgrep:
240+
enabled: true
241+
opengrep:
242+
enabled: true
243+
ruff:
244+
enabled: true
245+
246+
# File-type linters
178247
yamllint:
179248
enabled: true
180249
actionlint:
181250
enabled: true
182-
semgrep:
183-
enabled: true
184251
markdownlint:
185252
enabled: true
186-
github-checks:
187-
enabled: true
188-
timeout_ms: 120000
189253
dotenvLint:
190254
enabled: true
191255
checkmake:
192256
enabled: true
193257
osvScanner:
194258
enabled: true
259+
github-checks:
260+
enabled: true
261+
timeout_ms: 120000
195262

196-
# Disable irrelevant tools for Python project
263+
# Disable irrelevant tools for this Python project
264+
flake8:
265+
enabled: false
266+
pylint:
267+
enabled: false
197268
shellcheck:
198269
enabled: false
199270
biome:
@@ -246,6 +317,12 @@ reviews:
246317
enabled: false
247318
fortitudeLint:
248319
enabled: false
320+
stylelint:
321+
enabled: false
322+
blinter:
323+
enabled: false
324+
psscriptanalyzer:
325+
enabled: false
249326

250327
chat:
251328
art: true
@@ -258,11 +335,7 @@ knowledge_base:
258335
code_guidelines:
259336
enabled: true
260337
filePatterns:
261-
- "**/*.py"
262-
- "**/requirements*.txt"
263-
- "**/pyproject.toml"
264-
- "**/Dockerfile"
265-
- "**/*.{yml,yaml}"
338+
- ".github/copilot-instructions.md"
266339
learnings:
267340
scope: auto
268341
issues:
@@ -292,6 +365,7 @@ code_generation:
292365
- Use fixtures from conftest.py for TestClient
293366
- Use test stubs for consistent test data
294367
- Ensure async tests are properly decorated
368+
- Run via uv: uv run pytest -v --cov=./ --cov-report=xml --cov-report=term
295369
- Target 80% code coverage minimum
296370
297371
issue_enrichment:

0 commit comments

Comments
 (0)