Files
leo-claude-mktplace/plugins/projman/commands/project-init.md
lmiranda 0c2fc8c0d9 feat: add interactive setup wizard with API validation and mismatch detection
Major improvements to plugin setup experience:

Setup Commands:
- Redesign /initial-setup as interactive wizard (MCP + system + project config)
- Add /project-init for quick project-only setup
- Add /project-sync for handling repository moves/renames
- Add Gitea API validation to auto-fill org/repo when verified

Configuration Changes:
- Move GITEA_ORG from system to project level (supports multi-org users)
- System config now only contains GITEA_URL and GITEA_TOKEN
- Project .env now contains GITEA_ORG and GITEA_REPO

Automation:
- Add SessionStart hook for projman and pr-review
- Automatically detects git remote vs .env mismatch
- Warns user to run /project-sync when mismatch found

Documentation:
- Unify configuration docs (remove duplicate in plugins/projman)
- Add flow diagrams to CONFIGURATION.md
- Add setup script review guidance to UPDATING.md
- Update COMMANDS-CHEATSHEET.md with new commands and hooks

Files added:
- plugins/projman/commands/project-init.md
- plugins/projman/commands/project-sync.md
- plugins/projman/hooks/hooks.json
- plugins/pr-review/commands/initial-setup.md
- plugins/pr-review/commands/project-init.md
- plugins/pr-review/commands/project-sync.md
- plugins/pr-review/hooks/hooks.json
- plugins/cmdb-assistant/commands/initial-setup.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 11:20:36 -05:00

5.6 KiB

description
description
Quick project setup - configures only project-level settings (assumes system setup is complete)

Project Initialization

Fast setup for a new project when system-level configuration is already complete.

Use this when:

  • You've already run /initial-setup on this machine
  • You're starting work on a new project/repository
  • You just need to create the project .env file

Use /initial-setup instead if:

  • This is your first time using the plugin
  • MCP tools aren't working (might need system setup)

Pre-Flight Check

Step 1: Verify System Configuration Exists

Quickly verify system setup is complete:

cat ~/.config/claude/gitea.env 2>/dev/null | grep -v "^#" | grep -v "PASTE_YOUR" | grep "GITEA_TOKEN=" && echo "SYSTEM_OK" || echo "SYSTEM_MISSING"

If SYSTEM_MISSING:

Display this message and stop:


System configuration not found or incomplete.

It looks like the system-level setup hasn't been completed yet. Please run:

/initial-setup

This will configure both system credentials and this project.


If SYSTEM_OK: Continue to project setup.


Project Setup

Step 2: Verify Current Directory

pwd && git rev-parse --show-toplevel 2>/dev/null || echo "NOT_A_GIT_REPO"

If not a git repo, ask:

Use AskUserQuestion:

  • Question: "This doesn't appear to be a git repository. Continue anyway?"
  • Header: "Directory"
  • Options:
    • "Yes, continue here"
    • "No, I'll navigate to the correct directory"

Step 3: Check for Existing Configuration

cat .env 2>/dev/null | grep "GITEA_REPO=" || echo "NOT_CONFIGURED"

If already configured:

Use AskUserQuestion:

  • Question: "This project already has GITEA_ORG and GITEA_REPO configured. What would you like to do?"
  • Header: "Existing"
  • Options:
    • "Keep existing configuration"
    • "Reconfigure (replace current settings)"

If "Keep": End with success message.

Step 4: Detect Organization and Repository

Try to auto-detect from git remote:

git remote get-url origin 2>/dev/null

Extract organization:

git remote get-url origin 2>/dev/null | sed 's/.*[:/]\([^/]*\)\/[^/]*$/\1/'

Extract repository:

git remote get-url origin 2>/dev/null | sed 's/.*[:/]\([^/]*\)\.git$/\1/' | sed 's/.*\/\([^/]*\)$/\1/'

Step 5: Validate Repository via Gitea API

Verify the repository exists and is accessible:

source ~/.config/claude/gitea.env
curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITEA_TOKEN" "$GITEA_URL/api/v1/repos/<detected-org>/<detected-repo>"
HTTP Code Action
200 Auto-fill - display "Verified: / exists" and skip to Step 8
404 Repository not found - proceed to Step 6
401/403 Permission issue - warn and proceed to Step 6

Step 6: Confirm Organization (only if API validation failed)

Use AskUserQuestion:

  • Question: "Repository not found. Is '' the correct organization?"
  • Header: "Organization"
  • Options:
    • "Yes, that's correct"
    • "No, let me specify"

If "No", ask user to type the correct organization name.

Step 7: Confirm Repository Name (only if API validation failed)

Use AskUserQuestion:

  • Question: "Is '' the correct repository name?"
  • Header: "Repository"
  • Options:
    • "Yes, that's correct"
    • "No, let me specify"

If "No", ask user to type the correct name.

After corrections, re-validate via API (Step 5).

Step 8: Create/Update Project Configuration

If .env exists: Check if it already has other content and append:

echo "" >> .env
echo "# Added by /project-init" >> .env
echo "GITEA_ORG=<ORG_NAME>" >> .env
echo "GITEA_REPO=<REPO_NAME>" >> .env

If .env doesn't exist:

cat > .env << 'EOF'
# Project Configuration for projman
# Generated by /project-init

GITEA_ORG=<ORG_NAME>
GITEA_REPO=<REPO_NAME>
EOF

Step 9: Check .gitignore

grep -q "^\.env$" .gitignore 2>/dev/null && echo "GITIGNORE_OK" || echo "GITIGNORE_MISSING"

If GITIGNORE_MISSING:

Use AskUserQuestion:

  • Question: ".env is not in .gitignore. Add it to prevent committing secrets?"
  • Header: "gitignore"
  • Options:
    • "Yes, add .env to .gitignore (Recommended)"
    • "No, I'll handle it manually"

If yes:

echo ".env" >> .gitignore

Complete

Display success message:

╔══════════════════════════════════════════════════════════════╗
║                   PROJECT CONFIGURED                         ║
╠══════════════════════════════════════════════════════════════╣
║ Organization:  <ORG_NAME>                                    ║
║ Repository:    <REPO_NAME>                                   ║
║ Config file:   ./.env                                        ║
╚══════════════════════════════════════════════════════════════╝

You're ready to use projman commands:
• /sprint-plan    - Start sprint planning
• /sprint-status  - Check progress
• /labels-sync    - Sync label taxonomy

Troubleshooting

MCP tools not working?

  • Run /initial-setup for full setup including MCP server
  • Restart your Claude Code session after setup

Wrong repository configured?

  • Edit .env directly: nano .env
  • Or run /project-init again and choose "Reconfigure"