---
name: erp-kit-module-1-requirements
description: Create ERP module requirements and feature documentation. Use when starting a new module, defining requirements, scoping features, or designing module architecture. Guides collaborative research, scoping, and iterative feature breakdown.
disable-model-invocation: true
metadata:
  erp-kit-version: "0.59.0"
---

# Module Requirements Workflow

Autonomous workflow for creating ERP module requirements. Uses parallel agents for research, then automatically decides scope based on recommendations.

## Version Check

Run `npx erp-kit internal measure versions` from the repo root. If `status` is `"violations"`, relay the findings (each states its own fix) and stop; otherwise proceed.

## Workflow

```
SETUP → DISPATCH AGENTS → AGGREGATE & SCOPE → CREATE → REVIEW
```

## Step 1: Setup

Define shared context for all agents:

- `MODULES_ROOT`: glob `**/modules/*/README.md` and derive the parent directory
- `MODULE_NAME`: from argument or detect from current working directory
- `DOMAIN`: the business domain (e.g., "inventory management", "purchasing")
- `OTHER_MODULES`: glob `<MODULES_ROOT>/*/README.md` (to understand existing module landscape)

Infer MODULE_NAME and DOMAIN from the current working directory or argument context. If insufficient, use the module's README or directory name.

## Step 2: Dispatch Agents (parallelize if possible)

Launch 2 Agent tool calls in parallel — one per research concern.
Each agent receives: MODULE_NAME, DOMAIN, relevant context.

| Agent | Prompt Template                                                    | Inputs                             |
| ----- | ------------------------------------------------------------------ | ---------------------------------- |
| 1     | [references/erp-research.md](references/erp-research.md)           | MODULE_NAME, DOMAIN                |
| 2     | [references/boundary-analysis.md](references/boundary-analysis.md) | MODULE_NAME, DOMAIN, OTHER_MODULES |

For each agent:

1. Read the prompt template file
2. Replace `{{MODULE_NAME}}` with the resolved module name
3. Replace `{{DOMAIN}}` with the business domain
4. Replace `{{OTHER_MODULES}}` with the actual file paths
5. Dispatch the agent with the filled prompt

## Step 3: Aggregate & Scope Decision

After ALL agents return:

1. Collect findings from each agent
2. Build a **feature candidate table** by combining:
   - Features identified from ERP/SaaS research (Agent 1)
   - Module boundaries and dependencies (Agent 2)
3. For each feature, assign Include/Skip and the reasoning

Present as a **feature candidate list**:

### Feature Candidates

For each feature:

- **Feature:** feature name
- **Description:** what it does (1-2 sentences)
- **Recommendation:** `Include` or `Skip`
- **Why:** reasoning for the recommendation

The final feature set becomes the union of all `Include` features. Proceed with the recommended scope.

## Step 4: Create — Agent per feature

First, scaffold the module if it doesn't exist:

```bash
npx erp-kit module init <module-name> <MODULES_ROOT>/<module-name>
```

Then, for each `Include` feature, launch an Agent:

| Agent per feature | Prompt Template                                        | Inputs                                                           |
| ----------------- | ------------------------------------------------------ | ---------------------------------------------------------------- |
| N                 | [references/feature-doc.md](references/feature-doc.md) | MODULE_NAME, FEATURE_NAME, FEATURE_DESCRIPTION, RESEARCH_CONTEXT |

- `FEATURE_NAME`: the feature name from the candidate list
- `FEATURE_SLUG`: kebab-case version (e.g., `role-based-access-control`)
- `FEATURE_DESCRIPTION`: the description from the candidate list
- `RESEARCH_CONTEXT`: relevant findings from Agent 1 (ERP/SaaS research) for this feature

Parallelize across all features.

After all agents complete, run validation:

```bash
pnpm run module:doc:check
```

## Step 5: Review

**Split detection**: If a feature covers multiple distinct workflows, split into separate feature files automatically.

**Auto-split pattern:**

1. Detect features that cover multiple distinct workflows
2. Create new feature file for split-out content
3. Remove split content from original file
4. Update README.md feature list if needed

# Framework Schemas Reference

Schemas are bundled in `@tailor-platform/erp-kit`.

## Validation

Always run before completing:

```bash
pnpm run module:doc:check
```

## References

- [Module structure](../erp-kit-shared/references/structure.md)
