| name | business-rule-extraction |
| description | Extract business rules, boundary conditions, and exception handling strategies from source code across any language. Produces structured, auditable documentation for knowledge preservation, migration planning, and team onboarding.
|
| trigger | when the user requests business rule extraction, domain logic analysis, or migration knowledge mining |
| tags | ["business-rules","domain-logic","knowledge-mining","migration","analysis"] |
| profile | planning |
| supported-languages | ["java","kotlin","csharp","python","go","typescript"] |
| version | 2.0 |
| scope | platform |
| category | foundation |
Business Rule Extraction
Purpose
Systematically extract and document business rules embedded in source code. This is critical for:
- Migration projects: Understanding what the legacy system actually does before rebuilding
- Knowledge preservation: Capturing tribal knowledge locked in code
- Compliance audits: Mapping business policies to their code implementations
- Team onboarding: Giving new developers a business-level understanding of the system
When to Use
- Before a major technology migration (e.g., .NET → Java)
- When inheriting an undocumented legacy system
- During domain modeling for a new architecture
- When business stakeholders ask "what does the system actually do?"
Extraction Process
Step 1: Identify Business-Critical Code
Scan for classes/functions that contain domain logic (not infrastructure):
| Language | Look For |
|---|
| Java/Kotlin | *Service.java, *Validator.java, *Rule*.java, *Policy*.java, *Calculator*.java |
| C# | *Service.cs, *Validator.cs, *Handler.cs (MediatR), *Specification.cs |
| Python | services/*.py, rules/*.py, validators/*.py, domain/*.py |
| Go | *_service.go, *_handler.go, *_validator.go |
Skip infrastructure code: controllers, repositories, DTOs, config, migrations.
Step 2: Extract Rules Per Method
For each business method, extract:
A. Business Rules
Conditions and logic that enforce business policies.
Rule: BR-ORDER-001
Source: OrderService.kt:45 — calculateTotal()
Description: Orders over $500 qualify for free shipping
Condition: order.subtotal > 500.00
Action: shipping cost set to 0
B. Boundary Conditions
Edge cases and limits the system enforces.
Boundary: BC-ORDER-001
Source: OrderService.kt:52 — validateOrder()
Description: Maximum 99 items per order
Condition: order.items.size > 99
Action: throw MaxItemsExceededException