Generate Prompt
You are generating a comprehensive prompt that can be given to Claude Code (in a new session or shared with a teammate) to accomplish a development task. The prompt should include all the context Claude Code needs to be productive immediately.
Workflow
1. Gather User Intent
If the user didn't provide a task description with /generate-prompt, ask:
What do you want Claude Code to do? Describe the task, feature, bug fix, or change you need.
Get a clear understanding of:
- What needs to be done
- Any constraints or preferences
- Expected outcome
2. Analyze the Codebase
Gather context that Claude Code would need. Run these in parallel:
Project type and structure:
- Check for
package.json,Cargo.toml,pyproject.toml,go.mod, etc. to identify the tech stack - Read
CLAUDE.mdif it exists (contains project-specific instructions) - Read
README.mdfor project overview - Run
lson the root to understand top-level structure
Relevant files:
- Based on the user's task, identify which files and directories are most relevant
- Use Grep to find related code (function names, component names, API endpoints mentioned in the task)
- Read key files to understand patterns, conventions, and architecture
Dependencies and tools:
- Check dependency files for relevant libraries
- Check for config files (
.eslintrc,tsconfig.json,Makefile, etc.) - Check for test framework setup
Git context:
- Current branch:
git branch --show-current - Recent commits:
git log --oneline -5 - Any uncommitted changes:
git status --short
3. Generate the Prompt
Structure the prompt with these sections:
# Task
[Clear, actionable description of what to do]
## Context
- **Project**: [name, type, tech stack]
- **Key files**: [files most relevant to the task]
- **Branch**: [current branch]
## Codebase Overview
[Brief architecture summary relevant to the task — patterns used,
directory structure, key conventions from CLAUDE.md]
## Relevant Code
[Snippets or file references that show existing patterns, APIs,
or code that the task builds on or modifies]
## Requirements
[Specific requirements, constraints, and acceptance criteria]
## Implementation Hints
[Suggested approach based on codebase analysis — which files to modify,
patterns to follow, tests to write]
Prompt quality guidelines:
- Be specific, not generic — reference actual files, functions, and patterns from the codebase
- Include enough context that a fresh Claude Code session can start working immediately
- Don't dump entire files — include relevant snippets and file paths
- Mention conventions the project follows (from CLAUDE.md, commit style, test patterns)
- Include the "why" not just the "what"
4. Output the Prompt
Display the generated prompt in a code block so the user can copy it:
Here's your generated prompt:
```
[the full prompt]
```
5. Offer to Save
Ask if the user wants to save the prompt:
- Save to
.claude/prompts/<task-slug>.mdfor reuse - Create the directory if it doesn't exist
Arguments
| Argument | Effect |
|---|---|
| (none) | Interactive — ask what the user wants |
<task description> | Use the provided description directly |
--save | Auto-save the prompt to .claude/prompts/ |
Tips for Good Prompts
- Reference specific file paths so Claude Code can find them quickly
- Mention test files and testing patterns so Claude Code writes tests
- Include architectural constraints ("use the existing pattern in X")
- Specify output format if relevant ("create a new file at X")
- Mention what NOT to do if there are common pitfalls
