# Production Patterns Guide

Patterns observed in mature production skills that new skills should incorporate. Consult this during Step 5 (Round 1: Draft) and Step 6 (Round 2: Reflect).

---

## 1. Lesson-Learned Consultation

Before populating skill content, check lesson-learned files from related skills for reusable insights.

**Where to check:**
- `x-ipe-docs/skill-meta/{related-skill}/x-ipe-meta-lesson-learned.md`
- Related = same skill type, same domain, or same tool dependencies

**What to look for:**
- Anti-patterns already documented (avoid repeating them)
- Resource pipeline issues (file paths, naming)
- Tool loading failures (missing skill discovery)
- Session isolation requirements

---

## 2. Tool Skill Dependency Loading

When a skill references another skill or tool, it MUST load it explicitly — never guess behavior.

**Pattern** (from `x-ipe-task-based-code-implementation`):
```
1. DISCOVER: SCAN .github/skills/x-ipe-tool-{type}-*/ for available tool skills
2. READ CONFIG: Read x-ipe-docs/config/tools.json → extract relevant config section
3. FILTER: Match discovered tools against config (enabled/disabled)
4. LOAD: Read each enabled tool skill's SKILL.md before delegating
```

**When to apply:** Any skill that delegates work to tool skills or references other skills by name.

---

## 3. Config-Driven Behavior

Skills that support optional features must gate them via project config, not hardcode.

**Pattern** (from `x-ipe-task-based-bug-fix`):
```
READ CONFIG: x-ipe-docs/config/tools.json → stages.{stage}.{action}
- IF config has {tool-key} == true → feature ENABLED
- ELSE → feature DISABLED (skip gracefully)
```

**When to apply:** Browser testing, external tool integrations, optional sub-steps.

---

## 4. Anti-Patterns Section

Mature skills document common failure modes so agents avoid them.

**Template:**
```markdown
### Anti-Patterns

| Anti-Pattern | Why Bad | Do Instead |
|--------------|---------|------------|
| {bad practice} | {consequence} | {correct approach} |
```

**When to apply:** Any skill with 3+ steps where agents commonly take shortcuts or make recurring mistakes.

---

## 5. Limitations & Fallbacks

Document what the skill cannot handle, with workarounds.

**Template:**
```markdown
### Known Limitations

| Limitation | Workaround |
|------------|------------|
| {what doesn't work} | {what to do instead} |
```

**When to apply:** Tool skills with external dependencies (browsers, APIs, file formats). Task-based skills with scope boundaries.

---

## 6. Output Naming Conventions

Skills that produce artifacts (files, screenshots, reports) must define naming patterns.

**Pattern** (from `x-ipe-tool-knowledge-extraction-user-manual` lesson):
```
{section_number}-{subsection_number}-{descriptive-slug}.{ext}
Examples: 4-1-dashboard-overview.png, 5-2-data-export-steps.png
```

**When to apply:** Any skill that generates files in a folder (screenshots, reports, extracted content).
