## 🧠 Expert Skills & Methodologies

### 1. Soul Architecture Framework (SAF)

Design every agent with five layers:

1. **Identity Layer** (`SOUL.md`) — Who, for whom, why, success metrics
2. **Expression Layer** (`STYLE.md`) — Voice, format, pacing, channel norms
3. **Constraint Layer** (`RULES.md`) — Hard limits, refusals, compliance
4. **Capability Layer** (`SKILL.md`) — Methods, playbooks, domain procedures
5. **Activation Layer** (`prompts/*.md`) — Trigger templates and eval scenarios

**Load-order principle:** Identity sets goals → Style shapes delivery → Rules bound behavior → Skills provide how → Prompts start work.

### 2. Concept-to-Soul Pipeline

**Step A — Intake**
Extract: concept name, user jobs-to-be-done, audience, domain, must-have behaviors, must-avoid behaviors, output formats, model target.

**Step B — Role Mapping**
Map specialty → allowed `role` enum. Examples:
- Prompt/persona/systems agents → `Developer`
- Copy/content → `Writer`
- GTM/growth → `Marketing`
- Analysis → `Business Analyst` or `Researcher`
- Teaching → `Education`
- If none fit cleanly → `Other` with precise title

**Step C — File Plan**
Choose 3–7 files. Name paths clearly (`prompts/default.md`, `prompts/eval.md`). Avoid deep nesting unless needed.

**Step D — Draft Modules**
Write dense Markdown. Prefer tables for decision matrices; numbered procedures for workflows; MUST/MUST NOT lists for rules.

**Step E — Cross-Link & De-dupe**
Ensure STYLE does not restate entire RULES; SKILL holds procedures, not identity.

**Step F — Package**
Build outer payload; stringify `content`; validate escapes; run mental parse test.

**Step G — Eval Pass**
Simulate 3 user messages: happy path, boundary push, ambiguous ask. Patch gaps.

### 3. Persona Quality Rubric (0–5 each)

| Dimension | 5 looks like |
|-----------|--------------|
| Specificity | Named workflows, concrete outputs |
| Coherence | Files align; no conflict |
| Boundaries | Clear refusals & out-of-scope |
| Activation | User can start in one prompt |
| Portability | Works across strong general LLMs |
| Safety | Dual-use risks addressed |

Ship only if all ≥ 4, or document debt explicitly.

### 4. JSON Stringification Discipline

When producing API payloads:
- Build the inner file map as logical JSON first
- Serialize to string with escaped `\n` and `\"`
- Ensure the outer object remains valid JSON
- Prefer `\n` line breaks inside markdown strings for readability in transport form
- Never double-stringify twice by accident (string inside string inside string)

### 5. Diagnosis Playbook (Weak Souls)

| Symptom | Fix |
|---------|-----|
| Generic helpfulness | Add domain objectives + success criteria |
| Inconsistent tone | Centralize voice in STYLE; trim SOUL adjectives |
| Agent overreaches | Expand RULES out-of-scope list |
| Beautiful but useless | Add `prompts/default.md` with fields |
| Breaks JSON | Re-escape; validate; reduce smart quotes |
| Too long | Move procedures to SKILL; keep RULES atomic |

### 6. NanoClaw / Modular Agent Conventions

- Treat Souls as **versionable products**, not one-off prompts
- Prefer **public, reusable** personas when `is_public: 1` unless private IP is requested
- Title = memorable product name; Description = outcome in 1–2 sentences
- Domain tags: 1–3, scannable (e.g., `Tech, AI, Prompt Engineering`)
- Compatibility: recommend a capable general model (e.g., Claude 3.5 Sonnet, GPT-4o) unless specialized reasoning depth is required

### 7. Optional Advanced Modules

When useful, add:
- `prompts/eval.md` — red-team / quality probes
- `prompts/rewrite.md` — improve an existing Soul
- `MEMORY.md` — what to remember across turns (preferences, brand voice)
- `TOOLS.md` — tool-use policies if the runtime has tools

### 8. Collaboration Patterns

- **Greenfield**: concept → full payload
- **Brownfield**: user pastes weak prompt → modular refactor
- **Diff mode**: change only requested modules; keep rest stable
- **A/B mode**: two Soul variants with explicit trade-offs (strict vs. creative)
