| name | constructive-cli |
| description | Generated CLI commands and scaffolding — how the CLI is generated from GraphQL schemas, how to use it, codegen options, multi-target unified CLI, and the CLI reference. Use when asked to 'generate a CLI', 'create CLI commands', 'build a command-line client', 'run generated CLI', or when working with @constructive-io/graphql-codegen CLI output. |
| metadata | {"author":"constructive-io","version":"1.0.0"} |
Constructive CLI (Generated)
The Constructive codegen pipeline generates interactive command-line interfaces from GraphQL schemas using inquirerer. The generated CLI provides CRUD commands for each table and custom operations, plus built-in infrastructure commands for authentication and context management.
When to Apply
Use this skill when:
- Generating a CLI tool from a GraphQL schema
- Running or customizing the generated CLI
- Understanding the CLI codegen pipeline
- Building internal tooling or admin scripts from GraphQL APIs
- Configuring multi-target unified CLI output
How the CLI Is Generated
The CLI is generated by @constructive-io/graphql-codegen alongside the ORM client:
import { generate } from '@constructive-io/graphql-codegen';
await generate({
schemaFile: './schemas/public.graphql',
output: './generated',
cli: true,
});
CLI Configuration Options
cli: {
toolName: 'myapp',
entryPoint: true,
builtinNames: {
auth: 'credentials',
context: 'env',
},
}
Output Structure
{output}/cli/
├── index.ts # Entry point (only if entryPoint: true)
├── executor.ts # CLI executor with command routing
├── command-map.ts # Map of all commands
├── context.ts # Infrastructure: context management
├── auth.ts # Infrastructure: auth/credentials
├── utils.ts # Shared CLI utilities
└── commands/
├── users.ts # Generated CRUD commands per table
└── ...
Running the Generated CLI
npx ts-node generated/cli/index.ts
npx tsc && node dist/generated/cli/index.js
Built-in Infrastructure Commands
context — Manage API endpoints
myapp context create production --endpoint https://api.example.com/graphql
myapp context list
myapp context use production
myapp context current
auth — Manage API credentials
myapp auth set-token <your-bearer-token>
myapp auth status
myapp auth logout
Builtin Name Collision Handling
If a table name collides with auth or context, the infrastructure command is automatically renamed (auth → credentials, context → env). Override with builtinNames.
Multi-Target CLI (Unified)
Combine all targets into a single CLI with namespaced commands:
import { generateMulti } from '@constructive-io/graphql-codegen';
await generateMulti({
configs: {
public: { schemaFile: './schemas/public.graphql', output: './generated/public', cli: true },
admin: { schemaFile: './schemas/admin.graphql', output: './generated/admin', cli: true },
},
unifiedCli: { toolName: 'myapp', entryPoint: true },
});
Reference Guide
Cross-References
constructive-codegen skill (in constructive-skills) — Full codegen pipeline (hooks, ORM, CLI generation)
pgpm skill — Database migrations (deploy before generating CLI)
constructive-setup skill — Monorepo setup and local development