-  "CLAUDE.md.template": "<!-- PROMPTCODE-CLI-START -->\n# PromptCode CLI\n\nGenerate AI-ready prompts from your codebase. The CLI is designed to be AI-friendly with clear commands and outputs.\n\n## Quick Start\n\n```bash\n# Generate a prompt with specific files\npromptcode generate src/api/handler.ts src/utils/*.ts\n\n# Ask AI experts questions with code context\npromptcode expert \"Why is this slow?\" src/api/handler.ts\n\n# Use presets for common file patterns\npromptcode preset list                    # See available presets\npromptcode preset info <name>             # Show preset details & token count\npromptcode generate -l <preset-name>      # Generate using preset\n```\n\n## Working with Presets\n\nPresets are reusable file patterns stored in `.promptcode/presets/*.patterns`:\n\n```bash\n# Create a new preset\npromptcode preset create api-endpoints\n\n# Edit the preset file to add patterns\n# Then use it:\npromptcode generate -l api-endpoints\n```\n\n## Common Workflows for AI Agents\n\n### 1. Discovering Code Structure\n```bash\n# List all presets to understand project organization\npromptcode preset list\n\n# Inspect a preset to see what files it includes\npromptcode preset info functional-utils\n```\n\n### 2. Creating Focused Presets\nWhen asked to analyze specific features:\n1. Create a descriptive preset: `promptcode preset create feature-name`\n2. Edit `.promptcode/presets/feature-name.patterns` with relevant patterns\n3. Use `promptcode preset info feature-name` to verify file selection\n4. Generate output: `promptcode generate -l feature-name`\n\n### 3. Analyzing Code\n```bash\n# Generate prompt with specific concern\npromptcode generate src/**/*.ts --instructions \"Find performance bottlenecks\"\n\n# Or use expert mode for direct AI analysis\npromptcode expert \"Review this code for security issues\" src/api/**/*.ts\n```\n\n## Tips for AI Agents\n\n1. **Always check token counts** - Use `promptcode preset info` to see total tokens before generating\n2. **Be specific with patterns** - Use `src/api/*.ts` not `**/*.ts` to avoid huge contexts\n3. **Leverage existing presets** - Check `promptcode preset list` before creating new ones\n4. **Use descriptive preset names** - `auth-system` not `preset1`\n\n## Important: Cost Approval for AI Agents\n\nThe `expert` command includes built-in cost protection that requires approval for expensive operations (over $0.50 or using premium models). The CLI will automatically handle this in different environments:\n\n**In Interactive Mode (Terminal):**\n- The CLI will prompt the user directly for approval\n- Shows cost breakdown and waits for yes/no response\n\n**In Non-Interactive Mode (Claude Code, CI/CD):**\n```bash\n# Without approval flags, expensive operations will be blocked:\npromptcode expert \"Complex analysis\" --model o3-pro\n# Output: \"⚠️ Cost approval required for expensive operation (~$X.XX)\"\n#         \"Non-interactive environment detected.\"\n#         \"Use --yes to proceed with approval...\"\n```\n\n**AI Agent Approval Protocol:**\n1. **When you see \"Cost approval required\"**, STOP immediately\n2. **Inform the user**: \"This operation will cost approximately $X.XX. Do you want to proceed?\"\n3. **Wait for explicit user confirmation** (yes/no)\n4. **If approved**, re-run the command with `--yes` flag:\n   ```bash\n   promptcode expert \"Complex analysis\" --model o3-pro --yes\n   ```\n5. **If declined**, inform the user the operation was cancelled\n\n**Important Guidelines for AI Agents:**\n- **NEVER** automatically add `--yes` without explicit user consent\n- **ALWAYS** show the cost estimate before asking for approval\n- The `--yes` flag means \"I have user approval for this specific operation\"\n- The `--yes` flag can be used to auto-approve operations after user consent\n- Default to conservative behavior - when in doubt, ask for approval\n\n**Cost Information:**\n- Expensive models: o3-pro\n- Threshold: Operations over $0.50 require approval\n- The CLI shows detailed cost breakdowns before execution\n\n## Claude Code Integration\n\nWhen you run `promptcode cc`, it installs a custom command for Claude:\n- **`.claude/commands/expert-consultation.md`** - Allows Claude to properly use the expert command with cost approval\n\nThis command helps Claude:\n1. Check available presets and select appropriate context\n2. Handle cost approval properly (never auto-approving expensive operations)\n3. Use the correct model based on your request (o3 vs o3-pro)\n4. Parse and present results effectively\n\nTo use it in Claude, simply ask: \"Consult an expert about [your question]\"\n\n## Configuration\n\nAPI keys must be set via environment variables:\n```bash\nexport OPENAI_API_KEY=sk-...\nexport ANTHROPIC_API_KEY=sk-ant-...\nexport GOOGLE_API_KEY=...            # or GEMINI_API_KEY\nexport XAI_API_KEY=...                # or GROK_API_KEY\n```\n\n<details>\n<summary>⚠️ Troubleshooting</summary>\n\n• **Command not found** – The CLI auto-installs to `~/.local/bin`. Ensure it's in PATH  \n• **Missing API key** – Set via environment variable as shown above  \n• **Context too large** – Use more specific file patterns or create focused presets\n• **Preset not found** – Check `.promptcode/presets/` directory exists\n</details>\n<!-- PROMPTCODE-CLI-END -->",
0 commit comments