Skip to content

feat(init): add template system for project-type-aware setup#17

Merged
MrFlounder merged 1 commit intomainfrom
feat/init-templates
Feb 5, 2026
Merged

feat(init): add template system for project-type-aware setup#17
MrFlounder merged 1 commit intomainfrom
feat/init-templates

Conversation

@MrFlounder
Copy link
Copy Markdown
Contributor

Why

crab init previously generated a minimal config and relied on crab config scan to detect ports after the fact. For known project types like promptfoo-cloud, this left users with an incomplete config missing critical fields (port_spacing, install_env, admin-app/.env, API_PORT/PORT refs) -- the same gaps identified in PR #3185.

What

  • Added a template system with 4 new functions: template_promptfoo_cloud(), detect_template(), apply_template(), show_templates()
  • Rewrote show_init() to support:
    • --template <name> / -t <name> flag (with pf alias for promptfoo-cloud)
    • --list-templates flag
    • Auto-detection of project type from repo contents (checks .gitmodules for promptfoo submodule + server/.env.example)
  • Updated command routing to pass args through: show_init "${@:2}"
  • Updated help text to reflect new flags
  • Also updated Slack token config to prefer CRAB_SLACK_BOT_TOKEN env var over config file entry

The promptfoo-cloud template includes:

  • port_spacing: 10
  • install_env: PROMPTFOO_NODE_MODULES_CACHED=true
  • admin-app/.env in env_sync.files
  • API_PORT and PORT refs in env sync

How to Test

  1. crab init --list-templates -- should display the promptfoo-cloud template
  2. crab init -t promptfoo-cloud -- should apply the template and generate a full config
  3. crab init -t pf -- alias should also work
  4. Clone a promptfoo-cloud repo and run crab init -- should auto-detect and offer to apply the template
  5. Run crab init in a non-matching repo -- should fall through to the minimal 2-question setup

Add a template system to `crab init` that auto-detects project type and
applies pre-built configurations. Includes a promptfoo-cloud template
with port_spacing, install_env, admin-app/.env, and API_PORT/PORT refs.

New flags: --template/-t <name>, --list-templates. The `pf` alias maps
to promptfoo-cloud. Also updates Slack token config to prefer the
CRAB_SLACK_BOT_TOKEN env var over config file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MrFlounder MrFlounder merged commit 7229126 into main Feb 5, 2026
2 checks passed
@MrFlounder MrFlounder deleted the feat/init-templates branch February 5, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant