--- 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: ```bash cat ~/.config/claude/gitea.env 2>/dev/null | grep -v "^#" | grep -v "PASTE_YOUR" | grep "GITEA_API_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 ```bash 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 ```bash 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: ```bash git remote get-url origin 2>/dev/null ``` Extract organization: ```bash git remote get-url origin 2>/dev/null | sed 's/.*[:/]\([^/]*\)\/[^/]*$/\1/' ``` Extract repository: ```bash 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: ```bash source ~/.config/claude/gitea.env curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITEA_API_TOKEN" "$GITEA_API_URL/repos//" ``` | 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: ```bash echo "" >> .env echo "# Added by /project-init" >> .env echo "GITEA_ORG=" >> .env echo "GITEA_REPO=" >> .env ``` **If `.env` doesn't exist:** ```bash cat > .env << 'EOF' # Project Configuration for projman # Generated by /project-init GITEA_ORG= GITEA_REPO= EOF ``` ### Step 9: Check .gitignore ```bash 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: ```bash echo ".env" >> .gitignore ``` --- ## Complete Display success message: ``` ╔══════════════════════════════════════════════════════════════╗ ║ PROJECT CONFIGURED ║ ╠══════════════════════════════════════════════════════════════╣ ║ Organization: ║ ║ Repository: ║ ║ Config file: ./.env ║ ╚══════════════════════════════════════════════════════════════╝ You're ready to use projman commands: • /sprint-plan - Start sprint planning • /sprint-status - Check progress • /labels-sync - Sync label taxonomy ``` --- ## Visual Output When executing this command, display the plugin header: ``` ╔══════════════════════════════════════════════════════════════════╗ ║ 📋 PROJMAN ║ ║ ⚙️ SETUP ║ ║ Project Initialization ║ ╚══════════════════════════════════════════════════════════════════╝ ``` Then proceed with the project setup workflow. ## 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"