콘텐츠로 이동

CLI 레퍼런스

이 페이지에는 fastkit의 모든 명령과 그 옵션을 정리했습니다. 아래 블록에 있는 도움말은 fastkit <command> --help를 실행한 출력이므로, 언제나 설치된 버전의 내용과 일치합니다. 명령을 순서대로 따라 하며 익히고 싶다면 배우기 과정부터 시작하세요.

전역 옵션

전역 옵션은 fastkit --debug init처럼 명령 이름 앞에 씁니다.

  • --version은 설치된 버전(fastapi-fastkit, version 2.0.0)을 출력하고 종료합니다.
  • --debug는 fastkit이 수행하는 작업을 단계별로 보여 줍니다. 먼저 경고와 fastkit을 호출한 명령줄을 출력하고, 이어서 DEBUG 줄과 INFO 줄을 출력합니다. 이 줄에는 복사하는 템플릿 파일(DEBUG Copied ... to ...)과 복사한 파일을 수정한 내용(INFO Injected metadata into pyproject.toml)이 하나씩 나오며, 일반 실행에서는 생략되는 진행 메시지도 함께 나옵니다. 또한 출력하는 내용을 모두 설치된 fastapi_fastkit 패키지 안의 logs/fastkit.log(예: .venv/lib/python3.12/site-packages/fastapi_fastkit/logs/fastkit.log)에 기록합니다. 그 폴더에 쓸 수 없으면 fastkit은 ~/.fastapi-fastkit/logs/를 사용하고, 그곳에도 쓸 수 없으면 시스템 임시 디렉터리를 사용합니다. 기본값은 --no-debug입니다.
Usage: fastkit [OPTIONS] COMMAND [ARGS]...

  Create FastAPI projects from templates, then run, extend and check them.

Options:
  --debug / --no-debug  Show every internal step and diagnostic, and keep a copy
                        of the session in fastkit's log file. Put it before the
                        command: fastkit --debug init.
  --version             Show the version and exit.
  --help                Show this message and exit.

Commands:
  addroute        Add a new route to the FastAPI project.
  deleteproject   Delete a FastAPI project.
  doctor          Check a generated project for known problems and fix the...
  echo            About FastAPI-fastkit
  init            Create a FastAPI project.
  list-features   Display the list of available features and packages in...
  list-templates  Display the list of available templates.
  runserver       Run the FastAPI server for the current project.
  startdemo       Alias of 'fastkit init --template', kept for scripts...

  Start here:
    fastkit init                 create a project (guided)
    cd <project>
    fastkit runserver            run it at http://127.0.0.1:8000
    fastkit addroute users       add a route
    fastkit doctor               check it for known problems

fastkit init

레벨이나 번들 템플릿(--template), 저장해 둔 설정 파일(--config)로 프로젝트를 만듭니다. --template fastapi-sqlmodel로 만드는 프로젝트의 이름이 sqlmodel인 경우처럼, 프로젝트 이름이 그 프로젝트가 사용하는 의존성의 이름과 같으면 생성을 거부합니다. 이름이 같으면 패키지 관리자가 그 패키지를 설치하지 않기 때문입니다. 옵션을 실제로 사용하는 방법은 레벨 고르기와 기능 커스터마이즈하기에서 설명합니다.

Usage: fastkit init [OPTIONS]

  Create a FastAPI project.

  Asks for a project name and a level, then creates the project. Levels go from
  one main.py (hello) to a production layout (domain packages with PostgreSQL,
  Alembic, JWT, CI and Docker); production and the levels in between can be
  customised.

  --template copies a bundled template as it is (fastkit list-templates).
  --config replays a configuration saved with --save-config.

  Without a terminal nothing is asked: pass --project-name; everything else has
  a default. Exit status: 0 created, previewed or cancelled, 1 refused or
  failed, 2 invalid options.

  Examples:
    fastkit init
    fastkit init --level production --project-name shop
    fastkit init --template fastapi-sqlmodel --project-name notes
    fastkit init --project-name api --level domain --database SQLite \
        --feature authentication=JWT --no-venv -y

Options:
  --project-name, --name TEXT     Project name, also the folder name. Asked when
                                  missing and a terminal is available.
  --level [hello|single-file|layered|domain|production]
                                  Project level, from one main.py (hello) to a
                                  production layout (default: hello).
  --database [PostgreSQL|MySQL|MongoDB|Redis|SQLite|None]
                                  Database for the levels after hello (default:
                                  None; production: PostgreSQL).
  --feature AXIS=VALUE            Feature selection, repeatable:
                                  authentication=JWT, tooling=ruff,pre-commit.
                                  'fastkit list-features' shows the values.
                                  Levels after hello only.
  --extra-package TEXT            Additional package for the dependencies,
                                  repeatable. Levels after hello only.
  --template TEXT                 Copy a bundled template as it is instead of
                                  choosing a level (see 'fastkit list-
                                  templates').
  --config PATH                   Create the project from a saved configuration
                                  file (.json / .toml, .yaml with PyYAML),
                                  without prompts.
  --save-config PATH              Write this project's configuration to PATH for
                                  reuse with --config (skipped with --dry-run).
  --author TEXT                   Author name (default: git config user.name).
  --author-email TEXT             Author email (default: git config user.email).
  --description TEXT              Project description.
  --package-manager [pip|uv|pdm|poetry]
                                  Package manager (default: uv when installed,
                                  else pip).
  --in-place                      Write the project into the current directory
                                  instead of a new folder.
  --dry-run                       Show the files and packages that would be
                                  created, without writing anything.
  --no-venv                       Skip virtual environment creation (implies no
                                  dependency installation).
  --no-install                    Skip dependency installation.
  -y, --yes                       Use the defaults for every question that has
                                  one and create the project without asking;
                                  with --in-place, also allow overwriting files.
  --help                          Show this message and exit.

--dry-run은 요약과 파일 목록, 패키지 목록을 보여 줄 뿐이며 파일은 하나도 쓰지 않습니다.

$ fastkit init --level layered --name shop --dry-run -y
                                Project summary
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Setting         ┃ Value                                                      ┃
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Project name    │ shop                                                       │
│ Level           │ layered: Separate layers: routes, CRUD, schemas, core      │
│                 │ config.                                                    │
│ Template        │ fastapi-default                                            │
│ Database        │ None                                                       │
│ Features        │ None added: the template's own code and tests              │
│ Author          │ (not set)                                                  │
│ Package manager │ uv                                                         │
│ Environment     │ .venv with dependencies installed                          │
└─────────────────┴────────────────────────────────────────────────────────────┘

Files that would be created:
├── .env
├── .env.example
├── .gitattributes
├── .gitignore
├── README.md
├── pyproject.toml
├── requirements-dev.txt
├── requirements.txt
├── scripts/
...
└── tests/
    ├── __init__.py
    ├── conftest.py
    ├── test_config.py
    ├── test_item_store.py
    ├── test_items.py
    └── test_main.py

Packages that would be installed (via uv):
Packages
├── black>=26.10.1
├── fastapi>=0.141.1
├── httpx>=0.28.1
├── isort>=9.0.1
├── mypy>=2.3.1
├── opentelemetry-api>=1.44.0,<1.46
├── pydantic-settings>=2.15.0
├── pydantic>=2.13.5
├── pytest-cov>=7.1.0
├── pytest>=9.1.1
├── python-dotenv>=1.2.3
├── ruff>=0.17.6
└── uvicorn[standard]>=0.52.4
╭───────────────────── Info ──────────────────────╮
│ ℹ Dry run complete — no files were written.     │
╰─────────────────────────────────────────────────╯

fastkit addroute

프로젝트에 리소스(라우트, 스키마, 데이터 계층, 테스트)를 추가하고 그 라우터를 등록합니다. single-file 프로젝트에서는 라우트에 필요한 src/api, src/crud, src/schemas, src/core 패키지도 함께 만듭니다. hello 프로젝트에는 리소스를 추가하지 않으며, 대신 main.py에 엔드포인트를 직접 추가하라고 안내합니다. 자세한 과정은 앱 확장하기에서 단계별로 설명합니다.

Usage: fastkit addroute [OPTIONS] ROUTE_NAME [PROJECT_DIR]

  Add a new route to the FastAPI project.

  ROUTE_NAME is lower-case ASCII (letters, digits, underscores, starting with a
  letter); it names the modules and the URL segment. A route whose files already
  exist, or one named like an existing module of the project, is refused.

  Examples:
      fastkit addroute orders .            # Add 'orders' to the current directory
      fastkit addroute orders my_project   # Add 'orders' to 'my_project' in workspace
      fastkit addroute orders . --diff     # Preview the change without writing

  Exits with status 1 when it refuses to run (missing project directory, not a
  fastkit project, invalid route name or --entity, existing route) or planning
  or writing the route fails; a failed write is rolled back. Declining the
  confirmation prompt and a preview (--dry-run / --diff) exit with status 0.

Options:
  --layout [classic-layer|domain]
                                  Route layout. Defaults to domain for domain-
                                  starter projects and projects with a domains/
                                  package, otherwise classic-layer.
  --entity TEXT                   Singular PascalCase class name for the
                                  resource (e.g. Order). Derived from ROUTE_NAME
                                  when omitted.
  --dry-run                       List the files that would be created or
                                  modified; write nothing.
  --diff                          Like --dry-run, and also print a unified diff
                                  of each modified file and the content of each
                                  new file.
  --help                          Show this message and exit.

--diff는 파일 목록을 보여 준 다음, 수정되는 파일마다 변경 내용을 출력하고 새로 만드는 파일마다 전체 내용을 출력합니다. 다음은 layered 프로젝트에서 실행한 결과입니다.

$ fastkit addroute users . --diff
...
Files to create (4):
  + src/api/routes/users.py
  + src/crud/users.py
  + src/schemas/users.py
  + tests/test_users.py
Files to modify (2):
  ~ src/api/deps.py
  ~ src/api/api.py

--- a/src/api/deps.py
+++ b/src/api/deps.py
@@ -6,6 +6,7 @@
 from fastapi import Depends

 from src.crud.items import ItemStore, item_store
+from src.crud.users import UserRepository, get_user_repository


 def get_item_store() -> ItemStore:
@@ -16,3 +17,6 @@
 # An endpoint that declares `store: ItemStoreDep` gets what get_item_store() returns.
 # https://fastapi.tiangolo.com/tutorial/dependencies/
 ItemStoreDep = Annotated[ItemStore, Depends(get_item_store)]
+
+
+UserRepositoryDep = Annotated[UserRepository, Depends(get_user_repository)]

--- a/src/api/api.py
+++ b/src/api/api.py
@@ -6,9 +6,11 @@
 from src.api.routes import items

 # fastkit:imports
+from src.api.routes.users import router as users_router

 # One APIRouter collects the routers of every module; main.py mounts it once.
 # https://fastapi.tiangolo.com/tutorial/bigger-applications/
 api_router = APIRouter()
 api_router.include_router(items.router)
 # fastkit:routes
+api_router.include_router(users_router)

--- /dev/null
+++ b/src/api/routes/users.py
@@ -0,0 +1,111 @@
...

fastkit runserver

현재 디렉터리에 있는 프로젝트의 .venv를 사용해 uvicorn을 시작합니다. 실행할 애플리케이션은 pyproject.toml의 [tool.fastapi-fastkit] 블록에 있는 app_module 값으로 정해집니다(생성된 프로젝트 참고). 애플리케이션을 가져올 수 없는 경우처럼 서버가 오류로 멈추면, uvicorn이 출력하는 메시지가 먼저 나오고 fastkit이 출력하는 한 줄이 뒤따릅니다. 이때 runserver는 서버의 종료 상태를 그대로 사용해 종료합니다.

$ fastkit runserver
...
ModuleNotFoundError: No module named 'not_a_module'
╭───────────────────────────────── Error ──────────────────────────────────╮
│ ❌ The FastAPI server stopped with exit status 1; its messages above say │
│ why.                                                                     │
╰──────────────────────────────────────────────────────────────────────────╯
Usage: fastkit runserver [OPTIONS]

  Run the FastAPI server for the current project.

  In a FastAPI-fastkit project without a virtual environment (.venv), it prints
  the commands that create one and exits with status 1 unless you choose to
  continue with the current Python (the one running fastkit, which then needs
  uvicorn installed; without it runserver exits with status 1).

Options:
  --host TEXT             Host to bind the server  [default: 127.0.0.1]
  --port INTEGER          Port to bind the server  [default: 8000]
  --reload / --no-reload  Enable/disable auto-reload on code changes  [default:
                          reload]
  --workers INTEGER       Number of worker processes  [default: 1]
  --help                  Show this message and exit.

fastkit doctor

생성된 프로젝트에 알려진 문제가 있는지 검사하고, 안전하게 고칠 수 있는 문제를 고칩니다. 전체 실행 과정은 프로젝트 검사하고 고치기에서 볼 수 있습니다.

Usage: fastkit doctor [OPTIONS] [PATH]

  Check a generated project for known problems and fix the safe ones.

  Looks for the problems newer fastkit versions fixed in their templates: a
  committed or unignored .env, example SECRET_KEYs, an unauthenticated MCP
  server, CORS "*" with credentials, CRLF shell scripts, plain sqlalchemy
  without greenlet, and more. Never prints secret values.

  PATH is the project directory (default: the current directory).

  Exit status: 0 no problem found (or all fixed), 1 problems remain, 2 doctor
  could not run (not a fastkit project, unreadable project, a check failed, or
  --fix without --yes and without a terminal).

  --format json prints one JSON document (schema_version 1):
    schema_version, fastkit_version,
    project   {path, template, preset, generated_with, app_module,
               has_metadata},
    summary   {problems, fixable, by_severity {high, medium, low},
               checks {ok, problem, skipped, error}},
    checks    [{id, title, severity, status, fixable, note}],
    findings  [{check, severity, title, message, files, fixable,
                remediation}],
    fix       null, or {dry_run, planned [{path, check, summary,
               new_file, diff}], applied [path], failed [{path, reason}]},
    unreadable [{path, reason}]  (files that could not be read or
               parsed; the checks that needed them have status error),
    exit_code
  When doctor cannot run: {schema_version, fastkit_version, error,
  exit_code}. With json, --fix needs --yes or --dry-run.

Options:
  --fix                 Apply the safe fixes: show every change as a diff first,
                        then ask once. Advisory problems are never changed
                        automatically.
  --dry-run, --diff     Show the changes --fix would make, without writing
                        anything. Implies --fix.
  -y, --yes             Apply --fix changes without asking (required without a
                        terminal).
  --format [text|json]  Output format. json prints only the JSON document on
                        stdout.  [default: text]
  --force               Check a project without [tool.fastapi-fastkit] metadata
                        (generated before fastkit 1.4.0, or not by fastkit).
                        Checks that need the metadata are skipped.
  --help                Show this message and exit.

doctor가 수행하는 검사는 다음과 같습니다.

검사 제목 심각도
env-tracked .env is committed to git high
gitignore-env .gitignore does not keep .env out of git medium
env-example-missing .env exists but .env.example does not medium
example-secret An example secret shipped by fastkit is still in use high
session-secret Session signing key has a default value or is hard-coded high
mcp-auth The MCP server is created without authentication high
mcp-demo-users Hard-coded demo users are always enabled high
cors-credentials CORS allows every origin ("*") with credentials high
app-module-missing The recorded app entry point does not exist medium
prometheus-lifespan Prometheus instrumentation runs inside the lifespan medium
commit-after-yield A session dependency commits after yield medium
slowapi-middleware Default rate limit relies on SlowAPIMiddleware medium
pagination-demo fastapi-pagination demo router shadows the items list medium
motor-deprecated MongoDB is accessed through the deprecated Motor driver low
settings-sprawl Generated modules read configuration outside the settings module low
sqlalchemy-asyncio Async SQLAlchemy is used without greenlet medium
crlf-scripts Shell scripts or Dockerfiles have CRLF line endings medium
gitattributes-missing No .gitattributes pins LF line endings low
requires-python requires-python allows Python versions the template does not support low
pre-commit-python .pre-commit-config.yaml pins a python3.x interpreter low

fastkit list-templates

번들 템플릿을 설명과 함께 출력합니다. 모든 템플릿은 fastkit init --template으로 사용할 수 있습니다. 목록의 마지막 다섯 개는 예제 프로젝트이고, 나머지는 레벨 템플릿입니다.

Usage: fastkit list-templates [OPTIONS]

  Display the list of available templates.

Options:
  --help  Show this message and exit.

fastkit list-features

모든 기능 그룹을 옵션과 함께 출력하고, 옵션마다 추가되는 패키지도 보여 줍니다. 같은 데이터를 레벨과 기능 페이지에서도 볼 수 있습니다.

Usage: fastkit list-features [OPTIONS]

  Display the list of available features and packages in the catalog.

  Shows all available features that can be selected during interactive project
  creation, along with their associated packages.

Options:
  --help  Show this message and exit.

fastkit deleteproject

현재 디렉터리에 있는 프로젝트 폴더를 확인을 받은 뒤 삭제합니다. fastkit 프로젝트가 아닌 폴더는 삭제하지 않습니다.

Usage: fastkit deleteproject [OPTIONS] PROJECT_NAME

  Delete a FastAPI project.

  Exits with status 1 when the project does not exist, is not a FastAPI-fastkit
  project or cannot be deleted. Declining the confirmation exits with status 0.

Options:
  --help  Show this message and exit.

fastkit startdemo

fastkit 1.x용으로 작성된 스크립트가 계속 동작하도록 남겨 둔 명령입니다. 대응하는 fastkit init --template 명령을 알려 주는 한 줄을 출력한 다음 프로젝트를 만듭니다.

$ fastkit startdemo fastapi-hello --project-name demo --dry-run -y
Note: 'fastkit startdemo' is now 'fastkit init --template fastapi-hello'. startdemo keeps working.
Deploying FastAPI project using 'fastapi-hello' template
...

터미널에서 실행할 때 --project-name을 지정하지 않으면 프로젝트 이름을 묻습니다. -y를 지정하지 않으면 작성자 이름과 작성자 이메일, 설명도 묻습니다. 대체할 명령은 fastkit 1.x에서 업그레이드하기에 정리되어 있습니다.

Usage: fastkit startdemo [OPTIONS] [TEMPLATE]

  Alias of 'fastkit init --template', kept for scripts written for fastkit 1.x.

  Create a new FastAPI project from templates and inject metadata.

  Exits with status 1 when it refuses to run (unknown template, invalid project
  name, existing project directory, in-place overwrite without a terminal or
  --yes) or generation fails. Declining a confirmation prompt exits with status
  0.

  Non-interactive use:
      fastkit startdemo fastapi-default --project-name demo --author me \
          --author-email me@example.com --description demo \
          --package-manager uv -y </dev/null

Options:
  --project-name TEXT             The name of the new FastAPI project.
  --author TEXT                   The name of the project author (with -y: git
                                  config user.name).
  --author-email TEXT             The email of the project author (with -y: git
                                  config user.email).
  --description TEXT              The description of the new FastAPI project
                                  (with -y: empty).
  --package-manager [pip|uv|pdm|poetry]
                                  Package manager to use for the project.
  --dry-run                       Show the files and packages that would be
                                  created, without writing anything.
  --no-venv                       Skip virtual environment creation (implies no
                                  dependency installation).
  --no-install                    Skip dependency installation.
  -y, --yes                       Use the defaults instead of asking, as 'init
                                  -y' does: author and email from git config, an
                                  empty description, uv when installed (else
                                  pip), a new project folder; create the project
                                  without asking and, when deploying in place,
                                  overwrite existing files. Without a terminal,
                                  answers piped in are still read in the 1.x
                                  order; a question left without an answer takes
                                  its default.
  --help                          Show this message and exit.

fastkit echo

버전과 메인테이너, 저장소 주소를 출력합니다.

Usage: fastkit echo [OPTIONS]

  About FastAPI-fastkit

Options:
  --help  Show this message and exit.

환경 변수

fastkit이 읽는 환경 변수는 하나입니다.

변수 효과
FASTKIT_SUBPROCESS_TIMEOUT fastkit이 실행하는 모든 패키지 관리자 명령에 적용되는 제한 시간(초)입니다. 이 변수가 없으면 도구 확인에는 30초, 가상 환경 생성에는 120초, 의존성 설치에는 900초, 그 밖의 명령에는 300초가 적용됩니다. 양의 정수가 아닌 값은 무시합니다.
$ FASTKIT_SUBPROCESS_TIMEOUT=1800 fastkit init  # Windows (PowerShell): $env:FASTKIT_SUBPROCESS_TIMEOUT=1800