Check and fix a project
fastkit doctor checks a generated project for problems that newer fastkit templates fix, such as a committed .env, an example secret still in use, or shell scripts with CRLF line endings. It fixes the safe ones on request and never prints secret values. Upgrading fastkit never changes an existing project, so run doctor in your projects after an upgrade.
Run it
Run fastkit doctor in the project folder, or pass the folder as an argument. It prints a table of its checks; on a fresh project every check passes or is skipped:
$ fastkit init --level layered --name shop --no-venv -y
...
$ cd shop
$ fastkit doctor
fastkit doctor
template fastapi-default, preset classic-layered, generated with fastkit 2.0.0
...
╭────────────── Success ───────────────╮
│ ✨ No problems found. │
╰──────────────────────────────────────╯
A check is skipped when it does not apply, for example the MCP checks outside a fastapi-mcp project. The CLI reference lists every check with its severity.
Read the findings
The project below was put in a git repository with its .env committed by mistake (git add -f .env), and scripts/test.sh was saved with CRLF line endings. doctor reports each problem with the files concerned and how to fix it, then the checks table and a summary:
$ fastkit doctor
fastkit doctor
template fastapi-default, preset classic-layered, generated with fastkit 2.0.0
HIGH (1) ───────────────────────────────────────────────────────────────────────
[env-tracked] .env is committed to git
- .env is in the git index and is pushed with every commit.
How to fix:
Run `git rm --cached <file>` for each file listed and commit; the file stays
...
MEDIUM (1) ─────────────────────────────────────────────────────────────────────
[crlf-scripts] Shell scripts or Dockerfiles have CRLF line endings
- scripts/test.sh has CRLF line endings.
How to fix:
Convert the files to LF (the fix does) and add .gitattributes so Git keeps
them that way. With CRLF, `bash` fails with `$'\r': command not found` and
containers with `env: 'bash\r': No such file or directory`.
Fixable with `fastkit doctor --fix`.
...
╭──────────────────────────────── Warning ─────────────────────────────────╮
│ ⚠️ 2 problem(s) found (1 high, 1 medium). 1 can be fixed automatically: │
│ run `fastkit doctor --fix` to review and apply the changes. │
╰──────────────────────────────────────────────────────────────────────────╯
Fix the safe problems
--fix lists the changes it would make and asks once; --dry-run (or --diff) lists them and writes nothing. After the fix, doctor checks again and lists what is left. Advisory problems, such as the committed .env, are never changed automatically:
$ fastkit doctor --fix
...
Planned changes ────────────────────────────────────────────────────────────────
modify scripts/test.sh (convert scripts/test.sh from CRLF to LF line endings)
Apply these 1 file change(s)? [y/N]: y
updated scripts/test.sh
...
╭────────────── Warning ───────────────╮
│ ⚠️ 1 problem(s) found (1 high). │
╰──────────────────────────────────────╯
Follow the remediation by hand (git rm --cached .env, commit, rotate the secrets), and the next fastkit doctor ends with No problems found.
Use it in CI
Without a terminal, --fix needs --yes to write, or --dry-run to preview; otherwise it changes nothing and exits with status 2. --format json prints one JSON document for scripts; fastkit doctor --help describes its fields. Here is the summary part for the project with the committed .env:
$ fastkit doctor --format json
{
"schema_version": 1,
"fastkit_version": "2.0.0",
...
"summary": {
"problems": 1,
"fixable": 0,
...
The exit status tells a CI job what happened: 0 when no problem is found (or all were fixed), 1 when problems remain, 2 when doctor could not run.
Projects without fastkit metadata
doctor reads the [tool.fastapi-fastkit] table that fastkit writes into pyproject.toml. In a project generated before fastkit 1.4.0, or not by fastkit, it stops with exit status 2 and suggests --force. fastkit doctor --force checks such a project and skips the checks that need the metadata.