Skip to content

Refactor: reduce template redundancy in ecosystem-builder instruction #381

@FL4TLiN3

Description

@FL4TLiN3

Description

The ecosystem-builder instruction contains repetitive error handling guidance across multiple expert templates, violating the DRY principle and making updates error-prone.

Current State

Each template in ECOSYSTEM_BUILDER_INSTRUCTION repeats similar error handling guidance:

Main Expert Template:

## Error Handling
When errors occur, provide actionable guidance:
- "❌ Error: [what went wrong] | To fix: [specific steps]"
- Never fail silently - always explain what happened and how to resolve it

Setup Expert Template:

## Error Handling
When setup fails, guide the user:
- "❌ Failed: [what went wrong] | To fix: [specific steps]"
- Suggest running the doctor expert for diagnostics

Doctor Expert Template:

## Output Format
For issues: "❌ Issue: [problem] | To fix: [steps]"
If healthy: "✓ All checks passed! <name> is ready to use."

Issues:

  1. Three variations of the same "❌ ... | To fix: ..." pattern
  2. Slight inconsistencies (Error vs Failed vs Issue)
  3. Changes require updates in multiple places

Target State

Define error format once and reference it:

instruction = '''
...

## Error Format (applies to all ecosystem experts)
All errors must follow this format:
- "❌ [Type]: [description] | To fix: [actionable steps]"
- Type should be: Error, Failed, or Issue depending on context
- Never fail silently

For setup/doctor experts, also suggest related commands:
- Setup failures: "Run [name]-doctor for diagnostics"
- Doctor issues: "Run [name]-setup to reconfigure"

---

(Individual expert templates reference this shared format)
'''

Alternatively, extract error handling into instruction preamble that ecosystem-builder generates, rather than embedding in each template.

Affected Areas

  • apps/create-expert/src/lib/create-expert-toml.ts (ECOSYSTEM_BUILDER_INSTRUCTION)

Acceptance Criteria

  • No behavior changes
  • Error format defined once
  • All templates use consistent terminology
  • Easier to update error format globally

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