Skip to content

Refactor: convert procedural instructions to declarative domain knowledge in create-expert experts #376

@FL4TLiN3

Description

@FL4TLiN3

Description

The internal experts used by apps/create-expert use procedural step-by-step instructions, which violates Best Practice #2 "Trust the LLM, Define Domain Knowledge".

Current State

Most experts have numbered workflow steps:

instruction = """
## Workflow

1. **Extract Properties**: Delegate to `property-extractor` with user requirements
2. **Build Expert Ecosystem**: Delegate to `ecosystem-builder` with properties
3. **Integration Testing**: Delegate to `integration-manager`
4. **Generate Report**: Delegate to `report-generator`
"""

Similarly, expert-tester has procedural instructions:

### 1. Execute Tests
For each test case, run:
```bash
npx -y perstack run expert-name "test query" --workspace . --filter completeRun

### Target State

Per Best Practices, instructions should define **domain knowledge, not procedures**:

```toml
# BAD (procedural)
instruction = """
1. First, greet the customer
2. Ask for their order number
3. Look up the order
"""

# GOOD (declarative)
instruction = """
You are a customer support specialist.

Key policies:
- Orders ship within 2 business days
- Free returns within 30 days
"""

Instructions should define:

  • Role and capabilities
  • Domain rules and policies
  • Output expectations
  • When to use delegates (not step-by-step how)

Affected Experts

  • create-expert (coordinator)
  • property-extractor
  • ecosystem-builder
  • integration-manager
  • functional-manager
  • usability-manager
  • expert-tester
  • report-generator

Affected Areas

  • apps/create-expert/src/lib/create-expert-toml.ts

Acceptance Criteria

  • No behavior changes (same test outcomes)
  • Instructions describe domain knowledge, not procedures
  • LLM can reason about "what" to achieve, not "how" step-by-step
  • Follows patterns from docs/making-experts/best-practices.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    create-expertcreate-expert CLI packagerefactorCode improvement without behavior change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions