Skip to content

Rules

A rule is stable, preview (it runs only with preview = true), deprecated (it will be removed) or removed (documented for history).

architecture

How modules depend on each other: the layers and the direction of the imports.

Code Rule Standard Status Added in Default
BTARCH001 import-layers
A layer imports nothing of a layer above it
imports
CES-5 stable 0.12.0 on
BTARCH002 separate-orchestration
A function either orders the steps or does one of them
design
CES-8 preview 0.13.0 off
BTARCH003 architecture-vocabulary
Units are named with the architectural vocabulary of the house
naming
CES-16 preview 0.13.0 off

botica

What a run reports about itself: unreadable paths and suppression comments.

Code Rule Standard Status Added in Default
BT001 io-error
A path given on the command line cannot be read
stable 0.7.0 on
BT002 unused-suppression
A suppression comment that silences nothing
stable 0.7.0 on
BT003 invalid-suppression
A suppression comment that names an unknown rule or is malformed
stable 0.7.0 on
BT004 external-config
The file that an active external rule names holds the configuration of its tool
stable 0.10.0 on

cli

How command-line programs are written: the parser of the arguments.

Code Rule Standard Status Added in Default
BTCLI001 cli-typed-framework
Command-line interfaces use a typed, declarative framework
cli
CES-67 stable 0.8.0 on

config

How a program reads its configuration: the settings module, its class and the schema of the environment.

Code Rule Standard Status Added in Default
BTCONF001 settings-module
Environment is read only in the settings module
config
CES-76 stable 0.8.0 on
BTCONF002 settings-base-class
A settings class extends BaseSettings, not BaseModel
config
CES-76 preview 0.10.0 off
BTCONF003 settings-direct-instantiation
Settings are read through get_settings(), never built where they are used
config
CES-76 preview 0.10.0 off
BTCONF004 settings-env-schema
The variables of .env.schema and the fields of the settings classes match
config
CES-76 stable 0.12.0 on

data-models

Typed data at the boundaries: schemas, models, no raw dicts.

Code Rule Standard Status Added in Default
BTDM001 no-dict-alias
No type alias that hides a raw dict
typing
CES-79 stable 0.8.0 on
BTDM002 no-dict-call-return
No function returning dict(...)
typing
CES-79 stable 0.8.0 on
BTDM003 no-dict-literal-return
No function returning a dict literal
typing
CES-79 stable 0.8.0 on
BTDM004 no-dict-return-annotation
No function annotated to return a raw dict
typing
CES-79 stable 0.8.0 on

database

How code reaches a relational database: where the tables live and how the schema changes.

Code Rule Standard Status Added in Default
BTDB001 database-package
Relational persistence lives in a database package
layout
CES-18 stable 0.8.0 on
BTDB002 db-no-create-all
The schema changes through migrations, not metadata.create_all()
layout
CES-18 preview 0.10.0 off

fastapi

Rules for FastAPI services.

Code Rule Standard Status Added in Default
BTFAST001 api-schemas-extra-forbid
Request and response schemas reject unknown fields
typing
CES-4 stable 0.8.0 on
BTFAST002 api-schema-in-route-module
Pydantic schemas are not defined in route modules
typing
CES-17 preview 0.10.0 off
BTFAST003 api-request-schema-name
Request schemas are named {Name}Request
typing
CES-17 preview 0.10.0 off
BTFAST004 api-response-schema-name
Response schemas are named {Name}Response
typing
CES-17 preview 0.10.0 off

logging

How code logs and what it must not print.

Code Rule Standard Status Added in Default
BTLOG001 log-get-logger
Loggers come from the house get_logger
logging
CES-45 stable 0.8.0 on
BTLOG002 log-no-print
Libraries log, they don't print
logging
CES-46 stable 0.8.0 on

process

How changes are made: the scope of a pull request and its commits.

Code Rule Standard Status Added in Default
BTPROC001 pr-small-by-intent
A pull request carries one intent
review
CES-122 preview 0.13.0 off
BTPROC002 respect-local-repo
A change keeps the deliberate choices of the repository
review
CES-30 preview 0.13.0 off
BTPROC003 conventional-commits
Every commit subject follows Conventional Commits
commits
CES-75 preview 0.14.0 off
BTPROC004 no-ai-coauthorship
A commit message names no AI tool as a co-author or as the author of the change
commits
CES-91 preview 0.14.0 off

security

How code handles credentials: who checks them, how a token is decoded and where the browser keeps it.

Code Rule Standard Status Added in Default
BTSEC001 route-auth
Each route gets its caller from a dependency that verifies a credential
auth, fastapi
CES-121 preview 0.13.0 off
BTSEC002 jwt-verified
A decoded token has its signature and its expiry checked
auth, jwt
CES-121 preview 0.13.0 off
BTSEC003 no-token-in-web-storage
The browser keeps no credential in web storage
auth, browser
CES-121 preview 0.13.0 off

structure

Where code lives and how big it gets: file size, module naming, repository layout.

Code Rule Standard Status Added in Default
BTSTRUC001 file-size-guard
Keep source files small
size
CES-71 stable 0.7.0 on
BTSTRUC002 no-utils
No catch-all modules
naming
CES-63 stable 0.7.0 on
BTSTRUC003 no-artifacts-in-package
Keep data, models and reports outside the code
layout
CES-32 stable 0.7.0 on
BTSTRUC004 no-notebooks
Keep Jupyter notebooks outside the code
layout
CES-32 stable 0.7.0 on
BTSTRUC005 no-tests-in-package
Keep tests beside the package, not in it
layout
CES-32 stable 0.7.0 on
BTSTRUC006 cognitive-complexity
A function has a cognitive complexity of at most 15
complexity
CES-110 preview 0.10.0 off
BTSTRUC007 lockfile-committed
Each manifest has the lockfile of one package manager, committed
dependencies
CES-109 preview 0.13.0 off

testing

How tests are written and run.

Code Rule Standard Status Added in Default
BTTEST001 test-in-memory-adapters
Tests drive the logic through in-memory adapters, not mocks
tests
CES-64 preview 0.13.0 off
BTTEST002 test-through-interface
Tests assert on behaviour through the public interface
tests
CES-65 preview 0.13.0 off
BTTEST003 test-coverage-gap
A coverage gap is closed with a test that asserts a behaviour
tests, coverage
CES-66 preview 0.13.0 off
BTTEST004 no-coverage-pragma
No # pragma: no cover hides code from the coverage report
tests, coverage
CES-66 preview 0.14.0 off
BTTEST005 no-coverage-exclusion
The configuration of coverage leaves no code out of the report and keeps its threshold
tests, coverage
CES-66 preview 0.14.0 off
BTTEST006 coverage-exclusion-reachable
Coverage leaves out only code that no test can reach
tests, coverage
CES-66 preview 0.14.0 off

tooling

How the tools that check the code are configured: what keeps them on.

Code Rule Standard Status Added in Default
BTTOOL001 no-disabled-typecheck
The type checker stays on for the whole build and every file
types
CES-58 preview 0.13.0 off

writing

How text is written: documentation, commit messages, comments and the terms of the domain.

Code Rule Standard Status Added in Default
BTWRIT001 plain-writing
Text has none of the signs of model writing
writing
CES-120 preview 0.13.0 off
BTWRIT002 minimal-comments
A comment says only what the code cannot
writing
CES-120 preview 0.13.0 off
BTWRIT003 ubiquitous-language
One term per concept of the domain, the one of the glossary
writing
CES-120 preview 0.13.0 off