This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Default to Bun for local development in this repo.
- Prefer
bun run ...,bun test, andbun installover Node/npm/yarn/pnpm commands when operating on this CLI itself.
- Install dependencies:
bun install - Run the CLI entrypoint directly:
bun run src/index.ts - Run via package script:
bun run dev - Show CLI help:
bun run src/index.ts --help - Show help for a subcommand:
bun run src/index.ts plugin --help - Typecheck this repo:
bunx tsc --noEmit
There is currently no dedicated test script in package.json and no in-repo test suite yet. If tests are added with Bun, run them with bun test.
This repository is a Bun/TypeScript CLI for creating and managing FastAPI Best Architecture projects. The CLI itself is implemented in src/, while generated plugin scaffolds live in templates/.
src/index.tsis the single Commander entrypoint. It wires global flags (--project,--lang) and lazily imports command handlers for each subcommand.- Command groups are organized around user workflows rather than technical layers:
- project lifecycle:
create,list,remove,current,use,edit,go - development helpers:
dev,dev:web,dev:celery - plugin management:
plugin add|remove|create|list - infrastructure helpers:
infra start|stop - config mutation:
config set
- project lifecycle:
The CLI persists two JSON config layers:
- global config in
~/.fba.json, managed bysrc/lib/config.ts- stores language, current project, registered projects, and optional shell preference
- per-project config in
<project>/.fba.json, also managed bysrc/lib/config.ts- stores backend/frontend directory names, ports, and whether infra was provisioned
Most commands resolve the active project through resolveProjectDir()/requireProjectDir() semantics: explicit --project wins, otherwise the current project from global config is used.
src/commands/create.ts is the largest orchestration path and defines the mental model for the product:
- interactive onboarding and first-run language selection
- local environment checks (
python3,uv,pnpm, optionaldocker) viasrc/lib/env-check.ts - cloning the canonical backend and frontend starter repositories
- optional infra generation under
<project>/infraviasrc/lib/infra.ts - backend/frontend initialization and env file generation
- registration of the created project into
~/.fba.json
The create flow also includes rollback cleanup logic; if provisioning fails after the project directory is created, it removes the partially created project and tears down compose services if needed.
All shelling out is funneled through src/lib/process.ts:
run()wrapsexecafor buffered commands, optional spinners, and truncated error outputrunInherited()is used when the child process should own stdio, such asfba dev- tool/environment detection also uses this layer
If you need to add a new command that invokes external tools, follow this pattern instead of calling execa ad hoc.
Plugin support is split across three concerns:
- marketplace fetch/filter logic in
src/lib/plugin-market.ts- downloads a TypeScript data file from the upstream
fastapi-practices/pluginsrepo and extractspluginDataList
- downloads a TypeScript data file from the upstream
- local install/remove/scan logic in
src/lib/plugin-install.ts- frontend plugins are copied into the generated frontend under
apps/web-antdv-next/src/plugins - backend plugins live under
backend/plugin - backend plugin install/remove delegates to the generated backend's own
uv run fba ...commands
- frontend plugins are copied into the generated frontend under
- local plugin scaffolding in
src/commands/plugin/create.ts+src/lib/template.ts- templates are copied from
templates/serverortemplates/web {{var}}placeholders are replaced in both filenames and file contents- server templates choose between
plugin.app.tomlandplugin.ext.toml, then rename the selected file toplugin.toml
- templates are copied from
Plugin metadata contracts are defined in src/types/plugin.ts; plugin.toml is the source of truth for installed plugin metadata.
templates/ contains scaffold content that is copied into generated projects, not code executed by this CLI directly.
templates/server/is the backend plugin templatetemplates/web/is the frontend plugin template
When changing template behavior, inspect both the template files and src/lib/template.ts, because the runtime assumes specific filenames and placeholder conventions.
User-facing copy is centralized in src/lib/i18n.ts. src/index.ts initializes language from global config before registering commands, so command descriptions and interactive prompts come from the same translation table.
When adding a user-visible string, update both zh and en entries in src/lib/i18n.ts.
- The repo uses Bun to run the CLI, but the generated projects intentionally invoke external ecosystem tools like
uv,pnpm,git, anddocker; do not “Bun-convert” those generated-project workflows unless the product behavior itself is changing. src/lib/config.tsalso defines canonical path helpers for backend/frontend/plugin/infra directories. Reuse those helpers instead of rebuilding paths inline.- This repo currently mixes Bun-first guidance with some Node-style libraries (
execa,fs,path) in the implementation; preserve existing patterns unless you are intentionally refactoring the CLI internals.