Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:48:58 +08:00
commit df092d8cd2
127 changed files with 62057 additions and 0 deletions

View File

@@ -0,0 +1,395 @@
#!/bin/bash
# PRD Generator Script
# Interactive workflow for generating Product Requirements Documents
set -e
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ PRD Generator - Interactive Mode ║${NC}"
echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
echo ""
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL_DIR="$(dirname "$SCRIPT_DIR")"
# Check if template exists
TEMPLATE_FILE="$SKILL_DIR/references/prd_template.md"
if [ ! -f "$TEMPLATE_FILE" ]; then
echo -e "${RED}✗ Error: PRD template not found at $TEMPLATE_FILE${NC}"
exit 1
fi
# Function to prompt for input
prompt_input() {
local prompt="$1"
local var_name="$2"
local required="$3"
while true; do
echo -e "${YELLOW}${prompt}${NC}"
read -r input
if [ -n "$input" ]; then
eval "$var_name='$input'"
break
elif [ "$required" != "true" ]; then
eval "$var_name=''"
break
else
echo -e "${RED}This field is required. Please provide a value.${NC}"
fi
done
}
# Gather basic information
echo -e "${GREEN}Step 1: Basic Information${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
prompt_input "Feature/Product Name:" PRODUCT_NAME true
prompt_input "One-line Description:" DESCRIPTION true
prompt_input "Output Filename (default: ${PRODUCT_NAME// /_}_prd.md):" OUTPUT_FILE false
# Set default output file if not provided
if [ -z "$OUTPUT_FILE" ]; then
OUTPUT_FILE="${PRODUCT_NAME// /_}_prd.md"
OUTPUT_FILE=$(echo "$OUTPUT_FILE" | tr '[:upper:]' '[:lower:]')
fi
echo ""
echo -e "${GREEN}Step 2: Problem & Context${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
prompt_input "What problem are you solving?" PROBLEM true
prompt_input "Who are the primary users?" PRIMARY_USERS true
prompt_input "What are the key business goals?" BUSINESS_GOALS true
echo ""
echo -e "${GREEN}Step 3: Success & Scope${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
prompt_input "How will you measure success?" SUCCESS_METRICS true
prompt_input "Target launch date (or 'TBD'):" TIMELINE false
prompt_input "What's explicitly OUT of scope?" OUT_OF_SCOPE false
echo ""
echo -e "${GREEN}Step 4: PRD Type${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Select PRD type:"
echo " 1) Standard (comprehensive)"
echo " 2) Lean (streamlined)"
echo " 3) One-Pager (executive summary)"
echo ""
while true; do
read -p "Enter choice (1-3): " prd_type
case $prd_type in
1) PRD_TYPE="standard"; break;;
2) PRD_TYPE="lean"; break;;
3) PRD_TYPE="one-pager"; break;;
*) echo -e "${RED}Invalid choice. Please enter 1, 2, or 3.${NC}";;
esac
done
# Generate PRD
echo ""
echo -e "${BLUE}Generating PRD...${NC}"
echo ""
# Create PRD from template
cat > "$OUTPUT_FILE" << EOF
# Product Requirements Document: $PRODUCT_NAME
**Status:** Draft
**Author:** $(whoami)
**Date:** $(date +%Y-%m-%d)
**Last Updated:** $(date +%Y-%m-%d)
---
## Executive Summary
$DESCRIPTION
This PRD outlines the requirements for $PRODUCT_NAME, addressing the need to $PROBLEM for $PRIMARY_USERS.
---
## Problem Statement
### The Problem
$PROBLEM
### Impact
Without this feature/product, users experience [describe pain points].
### Why Now?
$BUSINESS_GOALS
---
## Goals & Objectives
### Business Goals
$BUSINESS_GOALS
### User Goals
- [User goal 1]
- [User goal 2]
- [User goal 3]
### Success Criteria
$SUCCESS_METRICS
---
## User Personas
### Primary User: $PRIMARY_USERS
**Demographics:**
- [Add demographic info]
**Behaviors:**
- [Add behavioral patterns]
**Needs:**
- [Add key needs]
**Pain Points:**
- [Add pain points]
---
## User Stories & Requirements
### Core User Stories
#### Story 1: [Feature Name]
**User Story:**
\`\`\`
As a [$PRIMARY_USERS],
I want to [action],
So that [benefit].
\`\`\`
**Acceptance Criteria:**
- [ ] [Criterion 1]
- [ ] [Criterion 2]
- [ ] [Criterion 3]
**Priority:** Must Have
---
#### Story 2: [Feature Name]
**User Story:**
\`\`\`
As a [user type],
I want to [action],
So that [benefit].
\`\`\`
**Acceptance Criteria:**
- [ ] [Criterion 1]
- [ ] [Criterion 2]
- [ ] [Criterion 3]
**Priority:** Should Have
---
## Success Metrics
### Key Performance Indicators (KPIs)
$SUCCESS_METRICS
### Measurement Plan
| Metric | Baseline | Target | Measurement Method |
|--------|----------|--------|-------------------|
| [Metric 1] | [Current value] | [Target value] | [How to measure] |
| [Metric 2] | [Current value] | [Target value] | [How to measure] |
---
## Scope
### In Scope
- [Feature/capability 1]
- [Feature/capability 2]
- [Feature/capability 3]
### Out of Scope
$OUT_OF_SCOPE
- [Explicitly excluded item 1]
- [Explicitly excluded item 2]
### Future Considerations
- [Potential future enhancement 1]
- [Potential future enhancement 2]
---
## Technical Considerations
### Architecture
[High-level technical approach]
### Dependencies
- **External APIs:** [List APIs]
- **Services:** [List services]
- **Libraries:** [List libraries]
### Security Requirements
- [Security requirement 1]
- [Security requirement 2]
### Performance Requirements
- [Performance requirement 1]
- [Performance requirement 2]
### Data Considerations
- [Data storage needs]
- [Data migration needs]
- [Privacy considerations]
---
## Design & UX Requirements
### User Experience
[Describe key UX principles and patterns]
### Visual Design
[Reference design system, mockups, or wireframes]
### Accessibility
- WCAG 2.1 Level AA compliance required
- Keyboard navigation support
- Screen reader compatibility
### Responsive Design
- Mobile support: [Yes/No/Details]
- Tablet support: [Yes/No/Details]
- Desktop support: [Yes/No/Details]
---
## Timeline & Milestones
**Target Launch:** $TIMELINE
### Phases
| Phase | Deliverables | Target Date |
|-------|-------------|-------------|
| Discovery | Requirements finalized, designs approved | [Date] |
| Development | Core functionality complete | [Date] |
| Testing | QA complete, bugs resolved | [Date] |
| Launch | Feature live in production | $TIMELINE |
---
## Risks & Mitigation
| Risk | Impact | Probability | Mitigation Strategy |
|------|--------|------------|-------------------|
| [Risk 1] | High/Med/Low | High/Med/Low | [How to mitigate] |
| [Risk 2] | High/Med/Low | High/Med/Low | [How to mitigate] |
---
## Dependencies & Assumptions
### Dependencies
- [Dependency 1]
- [Dependency 2]
### Assumptions
- [Assumption 1]
- [Assumption 2]
---
## Open Questions
- [ ] [Question 1]
- [ ] [Question 2]
- [ ] [Question 3]
---
## Stakeholder Sign-Off
| Stakeholder | Role | Status | Date |
|------------|------|--------|------|
| [Name] | Product Lead | Pending | - |
| [Name] | Engineering Lead | Pending | - |
| [Name] | Design Lead | Pending | - |
---
## Appendix
### References
- [Reference 1]
- [Reference 2]
### Change Log
| Date | Author | Changes |
|------|--------|---------|
| $(date +%Y-%m-%d) | $(whoami) | Initial draft |
EOF
echo -e "${GREEN}✓ PRD generated successfully!${NC}"
echo ""
echo -e "Output file: ${BLUE}$OUTPUT_FILE${NC}"
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo " 1. Review and fill in the placeholder sections"
echo " 2. Add specific user stories and acceptance criteria"
echo " 3. Attach mockups/wireframes if available"
echo " 4. Share with stakeholders for review"
echo " 5. Run validation: scripts/validate_prd.sh $OUTPUT_FILE"
echo ""
echo -e "${GREEN}✓ Done!${NC}"

View File

@@ -0,0 +1,298 @@
#!/bin/bash
# PRD Validation Script
# Checks PRD completeness and quality
set -e
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Default values
VERBOSE=false
SECTIONS="all"
# Usage function
usage() {
echo "Usage: $0 <prd_file.md> [options]"
echo ""
echo "Options:"
echo " --verbose Show detailed suggestions"
echo " --sections <list> Check specific sections only (comma-separated)"
echo " e.g., --sections user-stories,metrics"
echo ""
echo "Example:"
echo " $0 my_prd.md"
echo " $0 my_prd.md --verbose"
echo " $0 my_prd.md --sections user-stories,metrics"
exit 1
}
# Parse arguments
if [ $# -lt 1 ]; then
usage
fi
PRD_FILE="$1"
shift
while [[ $# -gt 0 ]]; do
case $1 in
--verbose)
VERBOSE=true
shift
;;
--sections)
SECTIONS="$2"
shift 2
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
usage
;;
esac
done
# Check if file exists
if [ ! -f "$PRD_FILE" ]; then
echo -e "${RED}✗ Error: File not found: $PRD_FILE${NC}"
exit 1
fi
echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ PRD Validation Report ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════╝${NC}"
echo ""
echo -e "File: ${BLUE}$PRD_FILE${NC}"
echo ""
# Counters
ISSUES_FOUND=0
WARNINGS=0
CHECKS_PASSED=0
# Function to check section exists
check_section() {
local section_name="$1"
local section_pattern="$2"
local required="$3"
if grep -q "$section_pattern" "$PRD_FILE"; then
echo -e "${GREEN}${NC} $section_name section found"
((CHECKS_PASSED++))
return 0
else
if [ "$required" = "true" ]; then
echo -e "${RED}${NC} $section_name section missing (REQUIRED)"
((ISSUES_FOUND++))
else
echo -e "${YELLOW}${NC} $section_name section missing (recommended)"
((WARNINGS++))
fi
return 1
fi
}
# Function to check content quality
check_content() {
local check_name="$1"
local pattern="$2"
local error_msg="$3"
if grep -q "$pattern" "$PRD_FILE"; then
echo -e "${YELLOW}${NC} $check_name: $error_msg"
((WARNINGS++))
return 1
else
echo -e "${GREEN}${NC} $check_name passed"
((CHECKS_PASSED++))
return 0
fi
}
echo -e "${BLUE}━━━ Section Completeness ━━━${NC}"
echo ""
# Required sections
check_section "Problem Statement" "##.*Problem Statement" true
check_section "Goals & Objectives" "##.*Goals.*Objectives" true
check_section "User Stories" "##.*User Stories" true
check_section "Success Metrics" "##.*Success Metrics" true
check_section "Scope" "##.*Scope" true
echo ""
echo -e "${BLUE}━━━ Recommended Sections ━━━${NC}"
echo ""
# Recommended sections
check_section "Executive Summary" "##.*Executive Summary" false
check_section "User Personas" "##.*User Personas" false
check_section "Technical Considerations" "##.*Technical Considerations" false
check_section "Design & UX Requirements" "##.*Design.*UX" false
check_section "Timeline & Milestones" "##.*Timeline.*Milestones" false
check_section "Risks & Mitigation" "##.*Risks.*Mitigation" false
echo ""
echo -e "${BLUE}━━━ Content Quality Checks ━━━${NC}"
echo ""
# Check for placeholder text
check_content "Placeholder text" "\[.*\]" "Contains placeholder brackets - fill in all placeholders"
# Check for TBD/TODO
check_content "TBD markers" "TBD\|TODO" "Contains TBD/TODO markers - resolve all open items"
# Check for empty sections
if grep -q "^##.*\n\n##" "$PRD_FILE"; then
echo -e "${YELLOW}${NC} Empty sections detected"
((WARNINGS++))
else
echo -e "${GREEN}${NC} No empty sections"
((CHECKS_PASSED++))
fi
# Check for user story format
echo ""
echo -e "${BLUE}━━━ User Story Validation ━━━${NC}"
echo ""
USER_STORY_COUNT=$(grep -c "As a.*I want.*So that" "$PRD_FILE" || true)
if [ "$USER_STORY_COUNT" -gt 0 ]; then
echo -e "${GREEN}${NC} Found $USER_STORY_COUNT properly formatted user stories"
((CHECKS_PASSED++))
# Check for acceptance criteria
AC_COUNT=$(grep -c "Acceptance Criteria" "$PRD_FILE" || true)
if [ "$AC_COUNT" -ge "$USER_STORY_COUNT" ]; then
echo -e "${GREEN}${NC} All user stories have acceptance criteria"
((CHECKS_PASSED++))
else
echo -e "${YELLOW}${NC} Some user stories may be missing acceptance criteria"
((WARNINGS++))
fi
else
echo -e "${RED}${NC} No properly formatted user stories found"
echo -e " Expected format: 'As a [user], I want [action], So that [benefit]'"
((ISSUES_FOUND++))
fi
# Check for success metrics
echo ""
echo -e "${BLUE}━━━ Metrics Validation ━━━${NC}"
echo ""
if grep -q "KPI\|metric\|measure" "$PRD_FILE"; then
echo -e "${GREEN}${NC} Success metrics mentioned"
((CHECKS_PASSED++))
# Check for quantifiable metrics
if grep -q "[0-9]\+%" "$PRD_FILE"; then
echo -e "${GREEN}${NC} Contains quantifiable metrics (percentages found)"
((CHECKS_PASSED++))
else
echo -e "${YELLOW}${NC} Consider adding quantifiable targets (%, numbers, etc.)"
((WARNINGS++))
fi
else
echo -e "${RED}${NC} Success metrics not clearly defined"
((ISSUES_FOUND++))
fi
# Check for scope definition
echo ""
echo -e "${BLUE}━━━ Scope Validation ━━━${NC}"
echo ""
IN_SCOPE=false
OUT_SCOPE=false
if grep -qi "in scope\|in-scope" "$PRD_FILE"; then
echo -e "${GREEN}${NC} In-scope section defined"
IN_SCOPE=true
((CHECKS_PASSED++))
else
echo -e "${YELLOW}${NC} In-scope section not clearly defined"
((WARNINGS++))
fi
if grep -qi "out of scope\|out-of-scope" "$PRD_FILE"; then
echo -e "${GREEN}${NC} Out-of-scope section defined"
OUT_SCOPE=true
((CHECKS_PASSED++))
else
echo -e "${YELLOW}${NC} Out-of-scope section not defined (prevents scope creep)"
((WARNINGS++))
fi
# Document quality checks
echo ""
echo -e "${BLUE}━━━ Document Quality ━━━${NC}"
echo ""
# Check word count
WORD_COUNT=$(wc -w < "$PRD_FILE")
echo -e "Word count: $WORD_COUNT"
if [ "$WORD_COUNT" -lt 500 ]; then
echo -e "${YELLOW}${NC} Document seems short for a PRD (< 500 words)"
((WARNINGS++))
elif [ "$WORD_COUNT" -gt 5000 ]; then
echo -e "${YELLOW}${NC} Document is very long (> 5000 words) - consider splitting"
((WARNINGS++))
else
echo -e "${GREEN}${NC} Document length appropriate"
((CHECKS_PASSED++))
fi
# Check for headers hierarchy
if grep -q "^#\s" "$PRD_FILE"; then
echo -e "${GREEN}${NC} Proper heading structure"
((CHECKS_PASSED++))
else
echo -e "${YELLOW}${NC} Check heading hierarchy (should start with # not ##)"
((WARNINGS++))
fi
# Final Summary
echo ""
echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Validation Summary ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════╝${NC}"
echo ""
echo -e "Checks passed: ${GREEN}$CHECKS_PASSED${NC}"
echo -e "Warnings: ${YELLOW}$WARNINGS${NC}"
echo -e "Issues found: ${RED}$ISSUES_FOUND${NC}"
echo ""
# Recommendations
if [ "$VERBOSE" = true ]; then
echo -e "${BLUE}━━━ Recommendations ━━━${NC}"
echo ""
echo "1. Ensure all required sections are present"
echo "2. Fill in all placeholder text marked with [brackets]"
echo "3. Use the user story format: 'As a [user], I want [action], So that [benefit]'"
echo "4. Include specific, measurable success metrics"
echo "5. Clearly define what's in and out of scope"
echo "6. Add acceptance criteria for all user stories"
echo "7. Review with stakeholders before finalizing"
echo ""
fi
# Exit code
if [ "$ISSUES_FOUND" -gt 0 ]; then
echo -e "${RED}❌ PRD validation failed${NC}"
echo -e " Address $ISSUES_FOUND critical issue(s) before proceeding"
exit 1
elif [ "$WARNINGS" -gt 0 ]; then
echo -e "${YELLOW}⚠ PRD validation passed with warnings${NC}"
echo -e " Consider addressing $WARNINGS warning(s) to improve quality"
exit 0
else
echo -e "${GREEN}✅ PRD validation passed!${NC}"
echo -e " Document looks ready for stakeholder review"
exit 0
fi