AgentSkillsCN

Requirement Analyzer

需求分析器

SKILL.md

Skill: requirement-analyzer

Purpose

Proactively identify, analyze, and resolve ambiguous or conflicting requirements before a single line of code is written. This skill prevents the agent from building the wrong thing.

When to Use

  • When a new prd.json is created or a new user story is added.
  • When the agent is unsure about the acceptance criteria.
  • As a pre-implementation check for every user story.

How It Works

This skill delegates analysis to a RequirementAnalyst Sub-Agent.

Step 1: Invoke the Sub-Agent

Before starting implementation of a user story, invoke the sub-agent:

bash
claude --print "You are a RequirementAnalyst sub-agent. Your task is to analyze the following user story for ambiguity and conflicts.

**User Story:**
$(jq '.userStories[] | select(.id == \"US-001\")' prd.json)

**Existing Codebase Summary:**
$(cat .ralph/codebase_index.json)

**Analysis Tasks:**
1. **Ambiguity Check**: Identify any vague or undefined terms in the acceptance criteria. Look for words like 'fast', 'user-friendly', 'better', 'intuitive', 'easy'.
2. **Conflict Check**: Does this story conflict with any existing functionality or other stories in the PRD?
3. **Completeness Check**: Are all edge cases covered? What happens on error?

**Output:**
- Ambiguity Score: 0-10 (0 = perfectly clear, 10 = completely ambiguous)
- Conflicts Found: List of conflicts, or 'None'.
- Clarifying Questions: A numbered list of questions for the human architect, or 'None'.
"

Step 2: Interpret the Output

Ambiguity ScoreAction
0-3Proceed with implementation.
4-6Log assumptions to progress.txt. Proceed with caution.
7-10Block the story. Mark as blocked-requirement.

Step 3: Handle Blocked Stories

If a story is blocked due to ambiguity:

  1. Update prd.json:

    json
    {
      "id": "US-001",
      "passes": "blocked-requirement",
      "clarification_needed": [
        "What does 'fast' mean? Please specify a target response time in milliseconds.",
        "Should the feature be available to guest users or only logged-in users?"
      ]
    }
    
  2. Log to progress.txt:

    markdown
    ## [Date] - US-001 Blocked
    - **Reason**: Ambiguous requirements (Score: 8/10).
    - **Clarifying Questions**: See prd.json.
    
  3. Move on to the next story.

Vague Keyword List

The sub-agent should flag the following keywords as potentially ambiguous:

  • fast, slow, quick, performant
  • user-friendly, intuitive, easy, simple
  • better, improved, enhanced
  • secure, safe (without specific criteria)
  • scalable, robust (without specific criteria)
  • etc., and so on, similar

Configuration

Add the following to your CLAUDE.md:

markdown
## Requirement Analysis

- **Ambiguity Threshold**: 6 (block if score > 6)
- **Vague Keywords**: fast, slow, user-friendly, intuitive, easy, simple, better, improved, secure, scalable
- **Autonomous Mode**: If enabled, agent will make reasonable assumptions and document them instead of blocking.