Loading...
Loading...
Use this when user needs to document business requirements from undocumented legacy code. Provides systematic 6-phase extraction: automated analysis, validation rules, use cases, business rules, data models, and workflow mapping. Apply for legacy system documentation, migration planning, compliance audits, or M&A due diligence
npx skill4agent add pearlthoughts/codecompass extract-requirementscodecompass batch:index <path>codecompass healthcodecompass requirements:extract --project-id <id> --output requirements.mdrequirements.md// Yii2 Model example
public function rules() {
return [
[['email', 'password'], 'required'],
['email', 'email'],
['password', 'string', 'min' => 8],
['age', 'integer', 'min' => 18],
];
}### User Registration Requirements
- REQ-001: Email address is mandatory
- REQ-002: Email must be valid format
- REQ-003: Password is mandatory
- REQ-004: Password minimum length: 8 characters
- REQ-005: User must be at least 18 years old// Controller actions → Use cases
public function actionCreate() {
// Use Case: Create New Order
}
public function actionApprove($id) {
// Use Case: Approve Order (with authorization check)
}
public function actionCancel($id) {
// Use Case: Cancel Order (business rules apply)
}## Order Management Use Cases
### UC-001: Create New Order
**Actor**: Customer
**Preconditions**: User authenticated
**Steps**:
1. User selects products
2. System validates inventory
3. User provides shipping address
4. System calculates total
5. Order created in pending status
### UC-002: Approve Order
**Actor**: Manager
**Preconditions**:
- Order in pending status
- User has 'manager' role
**Steps**:
1. Manager reviews order details
2. System validates business rules
3. Order status changed to approved
4. Notification sent to customercodecompass search:semantic "business validation rules for order approval"
codecompass search:semantic "conditions for discount calculation"
codecompass search:semantic "authorization checks for admin actions"CREATE TABLE orders (
id INT PRIMARY KEY,
status ENUM('pending', 'approved', 'shipped', 'cancelled'),
total DECIMAL(10,2) NOT NULL CHECK (total >= 0),
customer_id INT NOT NULL FOREIGN KEY REFERENCES customers(id),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);### Data Requirements
- REQ-010: Order must have unique identifier
- REQ-011: Order status: pending, approved, shipped, or cancelled
- REQ-012: Order total must be non-negative
- REQ-013: Order must be associated with a customer
- REQ-014: Order creation timestamp must be recordedOrder Status Flow:
pending → approved → shipped → delivered
↓
cancelled### Order Workflow
**States**: pending, approved, shipped, cancelled, delivered
**Transitions**:
- pending → approved (requires: manager approval)
- approved → shipped (requires: items in stock)
- shipped → delivered (requires: delivery confirmation)
- pending|approved → cancelled (requires: cancellation reason)
**Business Rules**:
- Cannot cancel after shipped
- Cannot approve if out of stock
- Refund required if cancelled after paymentifswitch/casecodecompass search:semantic "test cases for order validation"# Find all code related to "discount calculation"
codecompass search:semantic "discount calculation logic"
# Find all code related to "inventory management"
codecompass search:semantic "inventory stock management"# Business Requirements - [System Name]
## Functional Requirements
### FR-001: User Authentication
**Priority**: High
**Description**: System must authenticate users via email and password
**Acceptance Criteria**:
- Email validation follows RFC 5322
- Password minimum 8 characters
- Account locked after 5 failed attempts
**Source**: UserController::actionLogin(), User::validatePassword()
### FR-002: Order Approval Workflow
...{
"capabilities": {
"user_management": {
"features": ["register", "login", "reset_password"],
"rules": ["email_unique", "password_complexity"],
"roles": ["user", "admin"]
},
"order_processing": {
"features": ["create", "approve", "cancel", "ship"],
"rules": ["approval_required", "inventory_check"],
"workflow": "pending→approved→shipped→delivered"
}
}
}| UC ID | Use Case Name | Actor | Complexity |
|-------|---------------|-------|------------|
| UC-001 | Create Order | Customer | Medium |
| UC-002 | Approve Order | Manager | Low |
| UC-003 | Cancel Order | Customer/Manager | High |# For each requirement, verify in code
codecompass search:semantic "password must be at least 8 characters"| Requirement | Source Files | Tests |
|-------------|--------------|-------|
| REQ-001 | User.php:45, UserController.php:102 | UserTest.php:23 |
| REQ-002 | Order.php:78 | OrderTest.php:56 |if ($order->total < 1000) {
// No approval needed
}REQ: Orders under $1000 do not require manager approval$discount = ($customer->vip) ? 0.20 : 0.10;REQ: VIP customers receive 20% discount, regular customers 10%if (strtotime($order->created_at) > strtotime('-30 days')) {
// Can cancel
}REQ: Orders can only be cancelled within 30 days of creation0-discover-capabilities.mdsemantic-search.mdanalyze-yii2-project.md.ai/capabilities.jsonrequirementsbusiness-analyzersearchanalyzers