@c-a-f/cli
CLI tool to scaffold CAF (Clean Architecture Frontend) project structure. Creates the caf/ folder with domain, application, and infrastructure layers and example files.
Installation
Global (recommended on Windows):
npm install -g @c-a-f/cli
Run with npx (all platforms):
npx @c-a-f/cli
Windows users: if npx has issues with scoped packages, install globally and use caf-init.
Usage
Initialize in current directory
npx @c-a-f/cli
# or
caf-init
Initialize in a specific directory
npx @c-a-f/cli ./my-project
# or
caf-init ./my-project
What it creates
The CLI creates the following structure:
my-project/
├── caf/
│ ├── domain/ # Domain layer (entities, repository interfaces, services)
│ │ ├── User/
│ │ │ ├── user.entities.ts
│ │ │ ├── user.irepository.ts
│ │ │ ├── user.service.ts
│ │ │ └── index.ts
│ │ └── index.ts
│ ├── application/ # Application layer (use cases)
│ │ ├── User/
│ │ │ ├── Commands/
│ │ │ │ └── CreateUser.ts
│ │ │ ├── Queries/
│ │ │ │ └── GetUsers.ts
│ │ │ └── index.ts
│ │ └── index.ts
│ ├── infrastructure/ # Infrastructure layer (API, mocks)
│ │ ├── api/
│ │ │ ├── User/
│ │ │ │ ├── UserRepository.ts
│ │ │ │ ├── UserApi.ts
│ │ │ │ └── index.ts
│ │ │ └── index.ts
│ │ └── index.ts
│ └── index.ts
└── src/ # Your UI code
Default content
- Domain: User entity,
IUserRepositoryinterface, UserService. - Application: GetUsers query and CreateUser command.
- Infrastructure: UserRepository and UserApi implementations.
All files include proper imports and follow CAF conventions.
Next steps
After running the CLI:
- Install CAF dependencies:
npm install @c-a-f/core @c-a-f/infrastructure-react - Customize the generated files for your domain.
- Create your UI components in
src/. - Wire Plocs and UseCases at app root with
CAFProvider(see Infrastructure React).
Platform notes
- Windows: Package includes
caf-init.cmdfor compatibility; global install is recommended if npx fails. - Unix/Mac/Linux: Uses the
.jsfile with shebang;npx @c-a-f/clior globalcaf-initboth work.
Exports
CLI is a runnable package; no library exports. Commands: init (default), optionally with target directory.