Adds `mosaic prdy {init|update|validate}` subcommand:
- init: launches yolo Claude session with PRD-focused system prompt
- update: launches session to modify existing docs/PRD.md
- validate: bash-only completeness checker (15 checks against PRD guide)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
88 lines
3.0 KiB
Bash
88 lines
3.0 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
#
|
|
# prdy-init.sh — Create a new PRD via guided Claude session
|
|
#
|
|
# Usage:
|
|
# prdy-init.sh [--project <path>] [--name <feature>]
|
|
#
|
|
# Launches a dedicated Claude Code session in yolo mode with a specialized
|
|
# system prompt that guides the user through PRD creation. The output is
|
|
# written to docs/PRD.md.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/_lib.sh"
|
|
|
|
# ─── Parse arguments ─────────────────────────────────────────────────────────
|
|
|
|
PROJECT="."
|
|
NAME=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--project) PROJECT="$2"; shift 2 ;;
|
|
--name) NAME="$2"; shift 2 ;;
|
|
-h|--help)
|
|
cat <<'USAGE'
|
|
prdy-init.sh — Create a new PRD via guided Claude session
|
|
|
|
Usage: prdy-init.sh [--project <path>] [--name <feature>]
|
|
|
|
Options:
|
|
--project <path> Project directory (default: CWD)
|
|
--name <feature> Feature or project name (optional, Claude will ask if omitted)
|
|
|
|
Launches Claude Code in yolo mode with a PRD-focused system prompt.
|
|
The agent will ask clarifying questions, then write docs/PRD.md.
|
|
|
|
Examples:
|
|
mosaic prdy init
|
|
mosaic prdy init --name "User Authentication"
|
|
mosaic prdy init --project ~/src/my-app --name "Dashboard Redesign"
|
|
USAGE
|
|
exit 0
|
|
;;
|
|
*) echo "Unknown option: $1" >&2; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
# Expand tilde if passed literally (e.g., --project ~/src/foo)
|
|
PROJECT="${PROJECT/#\~/$HOME}"
|
|
|
|
# ─── Preflight checks ───────────────────────────────────────────────────────
|
|
|
|
_require_cmd "claude"
|
|
|
|
# Check for existing PRD
|
|
EXISTING="$(find_prd "$PROJECT")"
|
|
if [[ -n "$EXISTING" ]]; then
|
|
fail "PRD already exists: $EXISTING"
|
|
echo -e " Use ${C_CYAN}mosaic prdy update${C_RESET} to modify the existing PRD."
|
|
exit 1
|
|
fi
|
|
|
|
# Ensure docs/ directory exists
|
|
mkdir -p "$PROJECT/docs"
|
|
|
|
# ─── Build system prompt ─────────────────────────────────────────────────────
|
|
|
|
step "Launching PRD creation session"
|
|
|
|
SYSTEM_PROMPT="$(build_prdy_system_prompt "init")"
|
|
|
|
# Build kickoff message
|
|
if [[ -n "$NAME" ]]; then
|
|
KICKOFF="Create docs/PRD.md for the feature: ${NAME}. Read the project context first, then ask clarifying questions before writing the PRD."
|
|
else
|
|
KICKOFF="Create docs/PRD.md for this project. Read the project context first, then ask the user what they want to build. Ask clarifying questions before writing the PRD."
|
|
fi
|
|
|
|
# ─── Launch Claude ───────────────────────────────────────────────────────────
|
|
|
|
info "Output target: $PROJECT/$PRD_CANONICAL"
|
|
info "Mode: PRD Creation (yolo)"
|
|
echo ""
|
|
|
|
cd "$PROJECT"
|
|
exec claude --dangerously-skip-permissions --append-system-prompt "$SYSTEM_PROMPT" "$KICKOFF"
|