From 10624dd026a9964e24a7ef05f63ea05e56467a7b Mon Sep 17 00:00:00 2001 From: Tushar Mathur Date: Thu, 27 Nov 2025 20:28:23 +0530 Subject: [PATCH 1/3] feat(skills): add plan validation scripts to create-plan skill --- .forge/skills/create-plan/README.md | 98 +++++++++ .forge/skills/create-plan/SKILL.md | 15 +- .../skills/create-plan/validate-all-plans.sh | 76 +++++++ .forge/skills/create-plan/validate-plan.sh | 187 ++++++++++++++++++ 4 files changed, 374 insertions(+), 2 deletions(-) create mode 100644 .forge/skills/create-plan/README.md create mode 100755 .forge/skills/create-plan/validate-all-plans.sh create mode 100755 .forge/skills/create-plan/validate-plan.sh diff --git a/.forge/skills/create-plan/README.md b/.forge/skills/create-plan/README.md new file mode 100644 index 0000000000..5251a18fc8 --- /dev/null +++ b/.forge/skills/create-plan/README.md @@ -0,0 +1,98 @@ +# Create Plan Skill + +Tools and scripts for creating and validating implementation plans. + +## Files + +- `SKILL.md` - Main skill instructions for AI agents +- `validate-plan.sh` - Validates a single plan file +- `validate-all-plans.sh` - Validates all plans in a directory + +## Validation Scripts + +### validate-plan.sh + +Validates the structure and content of a single plan file. + +**Usage:** +```bash +./.forge/skills/create-plan/validate-plan.sh plans/2025-11-27-example-v1.md +``` + +**Checks:** +- ✓ Filename follows convention: `YYYY-MM-DD-task-name-vN.md` +- ✓ File is in `plans/` directory +- ✓ All required sections present: + - Main heading (`# Title`) + - `## Objective` + - `## Implementation Plan` + - `## Verification Criteria` + - `## Potential Risks and Mitigations` + - `## Alternative Approaches` +- ✓ Implementation Plan uses checkbox format (`- [ ]`) +- ✓ No numbered lists or plain bullets in Implementation Plan +- ✓ No code blocks (` ``` `) in the plan +- ✓ No code snippets (detects suspicious patterns) +- ✓ No placeholder tasks (TODO, TBD, etc.) +- ✓ Verification criteria have content +- ✓ Risks include mitigations +- ✓ Reasonable number of tasks (3-20) + +**Exit Codes:** +- `0` - Validation passed +- `1` - Validation failed (errors found) + +### validate-all-plans.sh + +Validates all plan files in a directory. + +**Usage:** +```bash +# Validate all plans in default directory (plans/) +./.forge/skills/create-plan/validate-all-plans.sh + +# Validate plans in custom directory +./.forge/skills/create-plan/validate-all-plans.sh path/to/plans +``` + +**Exit Codes:** +- `0` - All plans passed validation +- `1` - One or more plans failed validation + +## Integration + +### Pre-commit Hook + +Add to `.git/hooks/pre-commit`: + +```bash +#!/bin/bash +# Validate plans before committing + +if git diff --cached --name-only | grep -q "^plans/.*\.md$"; then + echo "Validating modified plans..." + ./.forge/skills/create-plan/validate-all-plans.sh plans/ + exit $? +fi +``` + +### CI/CD + +Add to your CI pipeline: + +```yaml +- name: Validate Plans + run: ./.forge/skills/create-plan/validate-all-plans.sh plans/ +``` + +## Example Valid Plan + +See `SKILL.md` for the complete plan template structure. + +## Common Validation Errors + +1. **Missing checkboxes**: Use `- [ ]` not `1.` or `-` +2. **Code blocks**: Plans should use natural language, not code +3. **Missing sections**: All required sections must be present +4. **Empty sections**: Sections should have meaningful content +5. **Incorrect filename**: Must follow `YYYY-MM-DD-task-name-vN.md` pattern diff --git a/.forge/skills/create-plan/SKILL.md b/.forge/skills/create-plan/SKILL.md index 7613c9ebc1..95b06106a9 100644 --- a/.forge/skills/create-plan/SKILL.md +++ b/.forge/skills/create-plan/SKILL.md @@ -1,6 +1,6 @@ --- name: create-plan -description: Generate detailed implementation plans for complex tasks. Creates comprehensive strategic plans in Markdown format with objectives, step-by-step implementation tasks using checkbox format, verification criteria, risk assessments, and alternative approaches. Use when users need thorough analysis and structured planning before implementation, when breaking down complex features into actionable steps, or when they explicitly ask for a plan, roadmap, or strategy. Strictly planning-focused with no code modifications. +description: Generate detailed implementation plans for complex tasks. Creates comprehensive strategic plans in Markdown format with objectives, step-by-step implementation tasks using checkbox format, verification criteria, risk assessments, and alternative approaches. All plans MUST be validated using the included validation script. Use when users need thorough analysis and structured planning before implementation, when breaking down complex features into actionable steps, or when they explicitly ask for a plan, roadmap, or strategy. Strictly planning-focused with no code modifications. --- # Create Implementation Plan @@ -33,7 +33,17 @@ Generate a Markdown plan file in `plans/` directory with naming: `plans/{YYYY-MM Example: `plans/2025-11-24-add-auth-v1.md` -### 3. Plan Structure +### 3. Validate Plan + +**MANDATORY:** Run the validation script to ensure the plan meets all requirements: + +```bash +./.forge/skills/create-plan/validate-plan.sh plans/{YYYY-MM-DD}-{task-name}-v{N}.md +``` + +Fix any errors or warnings and re-validate until the plan passes all checks. + +### 4. Plan Structure ```markdown # [Task Name] @@ -69,6 +79,7 @@ Example: `plans/2025-11-24-add-auth-v1.md` ## Critical Requirements +- **ALWAYS validate the plan** using `./.forge/skills/create-plan/validate-plan.sh` after creation - **ALWAYS use checkbox format** (`- [ ]`) for ALL implementation tasks - **NEVER use numbered lists** or plain bullet points in Implementation Plan section - **NEVER write code, code snippets, or code examples** in the plan diff --git a/.forge/skills/create-plan/validate-all-plans.sh b/.forge/skills/create-plan/validate-all-plans.sh new file mode 100755 index 0000000000..2614212d8c --- /dev/null +++ b/.forge/skills/create-plan/validate-all-plans.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# Validates all plan files in the plans directory +# Usage: ./validate-all-plans.sh [plans-directory] + +set -euo pipefail + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Get the directory of this script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +VALIDATOR="$SCRIPT_DIR/validate-plan.sh" + +# Check if validator exists +if [ ! -f "$VALIDATOR" ]; then + echo -e "${RED}Error:${NC} Validator script not found at $VALIDATOR" + exit 1 +fi + +# Make validator executable +chmod +x "$VALIDATOR" + +# Get plans directory (default to plans/ in project root) +PLANS_DIR="${1:-plans}" + +if [ ! -d "$PLANS_DIR" ]; then + echo -e "${RED}Error:${NC} Plans directory not found: $PLANS_DIR" + exit 1 +fi + +# Find all plan files +PLAN_FILES=$(find "$PLANS_DIR" -name "*.md" -type f | sort) + +if [ -z "$PLAN_FILES" ]; then + echo -e "${YELLOW}No plan files found in $PLANS_DIR${NC}" + exit 0 +fi + +# Count files +TOTAL_FILES=$(echo "$PLAN_FILES" | wc -l | tr -d ' ') +PASSED=0 +FAILED=0 + +echo -e "${BLUE}Validating $TOTAL_FILES plan file(s) in $PLANS_DIR${NC}" +echo "" + +# Validate each file +while IFS= read -r plan_file; do + echo -e "${BLUE}═══════════════════════════════════════════════${NC}" + if "$VALIDATOR" "$plan_file"; then + ((PASSED++)) + else + ((FAILED++)) + fi + echo "" +done <<< "$PLAN_FILES" + +# Final summary +echo -e "${BLUE}═══════════════════════════════════════════════${NC}" +echo -e "${BLUE}Summary:${NC}" +echo -e " Total: $TOTAL_FILES" +echo -e " ${GREEN}Passed: $PASSED${NC}" +echo -e " ${RED}Failed: $FAILED${NC}" +echo "" + +if [ $FAILED -eq 0 ]; then + echo -e "${GREEN}✓ All plans validated successfully!${NC}" + exit 0 +else + echo -e "${RED}✗ Some plans failed validation${NC}" + exit 1 +fi diff --git a/.forge/skills/create-plan/validate-plan.sh b/.forge/skills/create-plan/validate-plan.sh new file mode 100755 index 0000000000..642d9d5ec4 --- /dev/null +++ b/.forge/skills/create-plan/validate-plan.sh @@ -0,0 +1,187 @@ +#!/usr/bin/env bash +# Validates the structure and content of a plan file +# Usage: ./validate-plan.sh + +set -euo pipefail + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Counters +ERRORS=0 +WARNINGS=0 + +error() { + echo -e "${RED}✗ ERROR:${NC} $1" >&2 + ((ERRORS+=1)) +} + +warning() { + echo -e "${YELLOW}⚠ WARNING:${NC} $1" >&2 + ((WARNINGS+=1)) +} + +success() { + echo -e "${GREEN}✓${NC} $1" +} + +info() { + echo "ℹ $1" +} + +# Check if file path is provided +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +PLAN_FILE="$1" + +# Check if file exists +if [ ! -f "$PLAN_FILE" ]; then + error "File not found: $PLAN_FILE" + exit 1 +fi + +info "Validating plan: $PLAN_FILE" +echo "" + +# 1. Check file naming convention +FILENAME=$(basename "$PLAN_FILE") +if [[ ! "$FILENAME" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}-[a-z0-9-]+-v[0-9]+\.md$ ]]; then + error "Filename must follow pattern: YYYY-MM-DD-task-name-vN.md (got: $FILENAME)" +else + success "Filename follows naming convention" +fi + +# 2. Check file is in plans directory +if [[ ! "$PLAN_FILE" =~ plans/ ]]; then + warning "Plan should be in 'plans/' directory" +else + success "Plan is in 'plans/' directory" +fi + +# 3. Check required sections exist +CONTENT=$(cat "$PLAN_FILE") + +required_sections=( + "^# .+" + "^## Objective" + "^## Implementation Plan" + "^## Verification Criteria" + "^## Potential Risks and Mitigations" + "^## Alternative Approaches" +) + +section_names=( + "Main heading (# Title)" + "Objective section" + "Implementation Plan section" + "Verification Criteria section" + "Potential Risks and Mitigations section" + "Alternative Approaches section" +) + +for i in "${!required_sections[@]}"; do + if echo "$CONTENT" | grep -qE "${required_sections[$i]}"; then + success "${section_names[$i]} present" + else + error "Missing required section: ${section_names[$i]}" + fi +done + +# 4. Check for markdown checkboxes in Implementation Plan +if echo "$CONTENT" | sed -n '/^## Implementation Plan$/,/^## /p' | grep -qE '^\- \[ \]'; then + success "Implementation Plan uses checkbox format" +else + error "Implementation Plan must use checkbox format: - [ ] Task description" +fi + +# 5. Check for numbered lists in Implementation Plan (should not exist) +if echo "$CONTENT" | sed -n '/^## Implementation Plan$/,/^## /p' | grep -qE '^[0-9]+\.'; then + error "Implementation Plan should NOT use numbered lists (1., 2., 3.). Use checkboxes instead: - [ ]" +fi + +# 6. Check for plain bullet points in Implementation Plan (should not exist) +IMPL_SECTION=$(echo "$CONTENT" | sed -n '/^## Implementation Plan$/,/^## /p') +if echo "$IMPL_SECTION" | grep -E '^\- [^\[]' | grep -qv '^\- \[ \]'; then + error "Implementation Plan should NOT use plain bullet points (-). Use checkboxes instead: - [ ]" +fi + +# 7. Check for code blocks (should not exist) +CODE_FENCE='```' +if echo "$CONTENT" | grep -q "$CODE_FENCE"; then + error "Plan contains code blocks. Plans should NEVER include code, only natural language descriptions" +else + success "No code blocks found" +fi + +# 8. Check for suspicious code patterns (excluding valid references) +# Allow: `filepath:line` references, markdown formatting, tool names +# Disallow: code-like patterns with semicolons, braces, function calls +SUSPICIOUS_CODE=$(echo "$CONTENT" | grep -E '`[^`]*[{};()].*[{};()][^`]*`' | grep -v -E '`[a-zA-Z0-9_/.-]+:[0-9-]+`' || true) +if [ -n "$SUSPICIOUS_CODE" ]; then + warning "Potential code snippets detected (should use natural language instead):" + echo "$SUSPICIOUS_CODE" | head -3 +fi + +# 9. Check that checkboxes have meaningful content (not placeholders) +PLACEHOLDER_TASKS=$(echo "$CONTENT" | grep -E '^\- \[ \] (\[.*\]|TODO|TBD|\.\.\.|\.\.\.)' || true) +if [ -n "$PLACEHOLDER_TASKS" ]; then + warning "Found placeholder or template-style checkbox tasks:" + echo "$PLACEHOLDER_TASKS" +fi + +# 10. Check for empty sections +if echo "$CONTENT" | sed -n '/^## Objective$/,/^## /p' | grep -qE '^$' | grep -qE '^## '; then + warning "Objective section appears to be empty" +fi + +# 11. Check that verification criteria are specific (not empty) +VERIFICATION_CONTENT=$(echo "$CONTENT" | sed -n '/^## Verification Criteria$/,/^## /p' | tail -n +2 | grep -E '^\-' || true) +if [ -z "$VERIFICATION_CONTENT" ]; then + error "Verification Criteria section must contain specific, measurable criteria" +else + success "Verification Criteria section has content" +fi + +# 12. Check that risks have mitigations +RISKS_SECTION=$(echo "$CONTENT" | sed -n '/^## Potential Risks and Mitigations$/,/^## /p') +if echo "$RISKS_SECTION" | grep -qE '^[0-9]+\.|^\*\*'; then + if echo "$RISKS_SECTION" | grep -qi "mitigation"; then + success "Risks section includes mitigations" + else + warning "Risks section should include mitigation strategies" + fi +fi + +# 13. Check minimum number of checkboxes (at least 3 tasks) +CHECKBOX_COUNT=$(echo "$CONTENT" | grep -cE '^\- \[ \]' || true) +if [ -z "$CHECKBOX_COUNT" ]; then + CHECKBOX_COUNT=0 +fi +if [ "$CHECKBOX_COUNT" -lt 3 ]; then + warning "Implementation Plan has only $CHECKBOX_COUNT tasks. Consider breaking down into more specific steps." +elif [ "$CHECKBOX_COUNT" -gt 20 ]; then + warning "Implementation Plan has $CHECKBOX_COUNT tasks. Consider grouping or creating sub-plans." +else + success "Implementation Plan has $CHECKBOX_COUNT tasks" +fi + +# Final summary +echo "" +echo "================================================" +if [ $ERRORS -eq 0 ]; then + echo -e "${GREEN}✓ Validation passed${NC}" + if [ $WARNINGS -gt 0 ]; then + echo -e "${YELLOW} ($WARNINGS warnings)${NC}" + fi + exit 0 +else + echo -e "${RED}✗ Validation failed${NC}" + echo -e " ${RED}$ERRORS errors${NC}, ${YELLOW}$WARNINGS warnings${NC}" + exit 1 +fi From 9259d302395134319de504d4242b48ca44bc1439 Mon Sep 17 00:00:00 2001 From: Tushar Mathur Date: Thu, 27 Nov 2025 20:33:21 +0530 Subject: [PATCH 2/3] feat(skills): add comprehensive filename validation to plan validator --- .forge/skills/create-plan/validate-plan.sh | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.forge/skills/create-plan/validate-plan.sh b/.forge/skills/create-plan/validate-plan.sh index 642d9d5ec4..e0aca143c8 100755 --- a/.forge/skills/create-plan/validate-plan.sh +++ b/.forge/skills/create-plan/validate-plan.sh @@ -55,6 +55,53 @@ if [[ ! "$FILENAME" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}-[a-z0-9-]+-v[0-9]+\.md$ ]]; t error "Filename must follow pattern: YYYY-MM-DD-task-name-vN.md (got: $FILENAME)" else success "Filename follows naming convention" + + # Extract components for additional validation + if [[ "$FILENAME" =~ ^([0-9]{4})-([0-9]{2})-([0-9]{2})-([a-z0-9-]+)-v([0-9]+)\.md$ ]]; then + YEAR="${BASH_REMATCH[1]}" + MONTH="${BASH_REMATCH[2]}" + DAY="${BASH_REMATCH[3]}" + TASK_NAME="${BASH_REMATCH[4]}" + VERSION="${BASH_REMATCH[5]}" + + # 1a. Validate date is reasonable + CURRENT_YEAR=$(date +%Y) + if [ "$YEAR" -lt 2020 ] || [ "$YEAR" -gt $((CURRENT_YEAR + 1)) ]; then + error "Year $YEAR seems unreasonable (should be between 2020 and $((CURRENT_YEAR + 1)))" + fi + + if [ "$MONTH" -lt 1 ] || [ "$MONTH" -gt 12 ]; then + error "Month $MONTH is invalid (must be 01-12)" + fi + + if [ "$DAY" -lt 1 ] || [ "$DAY" -gt 31 ]; then + error "Day $DAY is invalid (must be 01-31)" + fi + + # 1b. Check task name is meaningful (not generic placeholders) + GENERIC_NAMES="^(task|test|plan|temp|tmp|example|sample|demo|foo|bar)$" + if [[ "$TASK_NAME" =~ $GENERIC_NAMES ]]; then + warning "Task name '$TASK_NAME' is too generic. Use a descriptive name." + fi + + # 1c. Check task name length (should be descriptive but not too long) + TASK_NAME_LENGTH=${#TASK_NAME} + if [ "$TASK_NAME_LENGTH" -lt 5 ]; then + warning "Task name '$TASK_NAME' is very short. Consider a more descriptive name." + elif [ "$TASK_NAME_LENGTH" -gt 60 ]; then + warning "Task name is very long ($TASK_NAME_LENGTH chars). Consider shortening." + fi + + # 1d. Check version number is reasonable + if [ "$VERSION" -gt 50 ]; then + warning "Version number $VERSION seems high. Are you sure this is correct?" + fi + + # 1e. Check for uppercase letters or underscores (should use hyphens) + if [[ "$FILENAME" =~ [A-Z_] ]]; then + error "Filename contains uppercase letters or underscores. Use lowercase and hyphens only." + fi + fi fi # 2. Check file is in plans directory From 88c9d234e56f9d9cafbaa4e43cfeb727ab61a536 Mon Sep 17 00:00:00 2001 From: Tushar Mathur Date: Thu, 27 Nov 2025 20:46:34 +0530 Subject: [PATCH 3/3] feat(skills): add task quality validation to plan validator --- .forge/skills/create-plan/README.md | 32 +++++- .forge/skills/create-plan/validate-plan.sh | 110 ++++++++++++++++++++- 2 files changed, 136 insertions(+), 6 deletions(-) diff --git a/.forge/skills/create-plan/README.md b/.forge/skills/create-plan/README.md index 5251a18fc8..ecafe90cdf 100644 --- a/.forge/skills/create-plan/README.md +++ b/.forge/skills/create-plan/README.md @@ -21,6 +21,13 @@ Validates the structure and content of a single plan file. **Checks:** - ✓ Filename follows convention: `YYYY-MM-DD-task-name-vN.md` + - Year is reasonable (2020 to current year + 1) + - Month is valid (01-12) + - Day is valid (01-31) + - Task name is meaningful (not generic like "test", "task", "temp") + - Task name length is reasonable (5-60 characters) + - Version number is reasonable (not > 50) + - No uppercase letters or underscores (use lowercase and hyphens only) - ✓ File is in `plans/` directory - ✓ All required sections present: - Main heading (`# Title`) @@ -34,6 +41,12 @@ Validates the structure and content of a single plan file. - ✓ No code blocks (` ``` `) in the plan - ✓ No code snippets (detects suspicious patterns) - ✓ No placeholder tasks (TODO, TBD, etc.) +- ✓ **Task quality and density:** + - Task descriptions are descriptive (≥ 20 characters recommended) + - Average task length is substantial (30-200 chars recommended) + - No generic/vague descriptions ("implement feature", "fix bug", etc.) + - No duplicate or highly similar tasks + - Consistent and sequential numbering if tasks are numbered - ✓ Verification criteria have content - ✓ Risks include mitigations - ✓ Reasonable number of tasks (3-20) @@ -91,8 +104,17 @@ See `SKILL.md` for the complete plan template structure. ## Common Validation Errors -1. **Missing checkboxes**: Use `- [ ]` not `1.` or `-` -2. **Code blocks**: Plans should use natural language, not code -3. **Missing sections**: All required sections must be present -4. **Empty sections**: Sections should have meaningful content -5. **Incorrect filename**: Must follow `YYYY-MM-DD-task-name-vN.md` pattern +1. **Invalid filename format**: Must follow `YYYY-MM-DD-task-name-vN.md` pattern + - Use lowercase letters only + - Use hyphens (not underscores) to separate words + - Use valid date (month 01-12, day 01-31, year 2020+) + - Avoid generic names like "test", "task", "temp" +2. **Missing checkboxes**: Use `- [ ]` not `1.` or `-` +3. **Code blocks**: Plans should use natural language, not code +4. **Missing sections**: All required sections must be present +5. **Empty sections**: Sections should have meaningful content +6. **Poor task quality**: Tasks should be descriptive and specific + - Avoid short descriptions like "Do this", "Fix that", "Update code" + - Avoid generic descriptions like "implement feature", "add functionality" + - Include rationale and context in task descriptions + - Aim for 30-150 characters per task description diff --git a/.forge/skills/create-plan/validate-plan.sh b/.forge/skills/create-plan/validate-plan.sh index e0aca143c8..8a3ca8a694 100755 --- a/.forge/skills/create-plan/validate-plan.sh +++ b/.forge/skills/create-plan/validate-plan.sh @@ -211,13 +211,121 @@ if [ -z "$CHECKBOX_COUNT" ]; then CHECKBOX_COUNT=0 fi if [ "$CHECKBOX_COUNT" -lt 3 ]; then - warning "Implementation Plan has only $CHECKBOX_COUNT tasks. Consider breaking down into more specific steps." + error "Implementation Plan has only $CHECKBOX_COUNT tasks. Plans must have at least 3 tasks." +elif [ "$CHECKBOX_COUNT" -lt 5 ]; then + warning "Implementation Plan has only $CHECKBOX_COUNT tasks. Consider adding more detailed steps." elif [ "$CHECKBOX_COUNT" -gt 20 ]; then warning "Implementation Plan has $CHECKBOX_COUNT tasks. Consider grouping or creating sub-plans." else success "Implementation Plan has $CHECKBOX_COUNT tasks" fi +# 14. Check task quality and density +if [ "$CHECKBOX_COUNT" -gt 0 ]; then + # Extract all task lines + TASKS=$(echo "$CONTENT" | sed -n '/^## Implementation Plan$/,/^## /p' | grep --color=never -E '^\- \[ \]') + + # 14a. Check for very short tasks (< 20 chars after checkbox) + SHORT_TASKS="" + SHORT_COUNT=0 + while IFS= read -r task; do + # Remove "- [ ] " prefix and numbering + TASK_TEXT=$(echo "$task" | sed 's/^- \[ \] //' | sed 's/^[0-9]*\. *//') + if [ ${#TASK_TEXT} -lt 20 ] && [ ${#TASK_TEXT} -gt 0 ]; then + SHORT_TASKS="$SHORT_TASKS$TASK_TEXT"$'\n' + SHORT_COUNT=$((SHORT_COUNT + 1)) + fi + done <<< "$TASKS" + + if [ "$SHORT_COUNT" -gt 0 ]; then + warning "Found $SHORT_COUNT task(s) with very short descriptions (< 20 chars). Tasks should be descriptive." + echo "$SHORT_TASKS" | head -3 | sed 's/^/ - /' + fi + + # 14b. Check for generic/vague task descriptions + GENERIC_PATTERNS="(implement feature|add functionality|fix bug|update code|make changes|do work|complete task|finish|setup|configure)" + GENERIC_TASKS=$(echo "$TASKS" | grep -iE "$GENERIC_PATTERNS" || true) + if [ -n "$GENERIC_TASKS" ]; then + warning "Found tasks with generic/vague descriptions. Be more specific about what needs to be done." + echo "$GENERIC_TASKS" | head -3 | sed 's/^/ /' + fi + + # 14c. Check average task length (should be descriptive) + TOTAL_LENGTH=0 + TASK_COUNT=0 + while IFS= read -r task; do + TASK_TEXT=$(echo "$task" | sed 's/^- \[ \] //' | sed 's/^[0-9]*\. *//') + TASK_LEN=${#TASK_TEXT} + TOTAL_LENGTH=$((TOTAL_LENGTH + TASK_LEN)) + TASK_COUNT=$((TASK_COUNT + 1)) + done <<< "$TASKS" + + if [ "$TASK_COUNT" -gt 0 ]; then + AVG_LENGTH=$((TOTAL_LENGTH / TASK_COUNT)) + if [ "$AVG_LENGTH" -lt 30 ]; then + warning "Average task description length is only $AVG_LENGTH characters. Tasks should be more detailed and include rationale." + elif [ "$AVG_LENGTH" -gt 200 ]; then + warning "Average task description length is $AVG_LENGTH characters. Consider breaking down complex tasks." + else + success "Task descriptions have good detail level (avg: $AVG_LENGTH chars)" + fi + fi + + # 14d. Check for potential duplicate or very similar tasks + # Compare each task with others for similarity + TASK_ARRAY=() + while IFS= read -r task; do + TASK_TEXT=$(echo "$task" | sed 's/^- \[ \] //' | sed 's/^[0-9]*\. *//' | tr '[:upper:]' '[:lower:]') + TASK_ARRAY+=("$TASK_TEXT") + done <<< "$TASKS" + + SIMILAR_FOUND=false + for i in "${!TASK_ARRAY[@]}"; do + for j in "${!TASK_ARRAY[@]}"; do + if [ "$i" -lt "$j" ]; then + TASK1="${TASK_ARRAY[$i]}" + TASK2="${TASK_ARRAY[$j]}" + # Check if tasks are very similar (same first 30 chars) + TASK1_PREFIX="${TASK1:0:30}" + TASK2_PREFIX="${TASK2:0:30}" + if [ -n "$TASK1_PREFIX" ] && [ "$TASK1_PREFIX" = "$TASK2_PREFIX" ]; then + if [ "$SIMILAR_FOUND" = false ]; then + warning "Found potentially duplicate or very similar tasks. Review for redundancy." + SIMILAR_FOUND=true + fi + fi + fi + done + done + + # 14e. Check task numbering consistency + NUMBERED_TASKS=$(echo "$TASKS" | grep --color=never -E '^\- \[ \] [0-9]+\.') + if [ -n "$NUMBERED_TASKS" ]; then + NUMBERED_COUNT=$(echo "$NUMBERED_TASKS" | wc -l | tr -d ' ') + if [ "$NUMBERED_COUNT" -eq "$CHECKBOX_COUNT" ]; then + # All tasks are numbered - check sequence + NUMBERS=$(echo "$NUMBERED_TASKS" | sed 's/^- \[ \] \([0-9]*\)\..*/\1/') + EXPECTED=1 + SEQUENCE_OK=true + while IFS= read -r num; do + if [ "$num" -ne "$EXPECTED" ]; then + SEQUENCE_OK=false + break + fi + EXPECTED=$((EXPECTED + 1)) + done <<< "$NUMBERS" + + if [ "$SEQUENCE_OK" = true ]; then + success "Task numbering is consistent and sequential" + else + warning "Task numbering is inconsistent. Should be sequential: 1, 2, 3, ..." + fi + elif [ "$NUMBERED_COUNT" -gt 0 ]; then + warning "Only $NUMBERED_COUNT of $CHECKBOX_COUNT tasks are numbered. Be consistent." + fi + fi +fi + # Final summary echo "" echo "================================================"