---
phase: 45-content-as-skills
plan: 01
subsystem: skills
tags: [skill-registry, content-generation, local-nexus-content, creative-group, libsql, drizzle]

# Dependency graph
requires:
  - phase: 40-job-infrastructure
    provides: content_jobs table and renderContent dispatcher with all 9 jobTypes
  - phase: 41-diagrams-icons-theme-engine
    provides: diagram, icon-set, theme-palette renderers
  - phase: 42-wallpapers-social-format-conversion-voice
    provides: wallpaper, social-post, convert renderers
  - phase: 43-documents-branding
    provides: pdf-document, brand-kit renderers
  - phase: 44-video-presentations
    provides: presentation renderer
provides:
  - 9 SKILL.md files in server/src/skills/content/ with frontmatter, jobType docs, and output docs
  - local-nexus-content source type in skill-registry-fetcher.ts
  - fetchLocalNexusContent function that reads .SKILL.md files, computes SHA-1 hash, upserts skills
  - nexus-content entry in BUILT_IN_SOURCES pointing to local skills/content dir
  - seedCreativeGroupMembers() export in skill-registry-db.ts seeding 9 content skills into builtin/creative group
  - getRawClient() export for test access to raw LibSQL client
  - Unified startup block in index.ts: DB init -> fetchAll -> seedCreativeGroupMembers -> reconcile pending groups
  - 9 unit tests for SKILL.md files, fetchLocalNexusContent, and Creative group seeding
affects: [agents-with-creative-group, skill-registry-api, pendingSkillGroups-reconciler]

# Tech tracking
tech-stack:
  added: []
  patterns:
    - local-nexus-content source type: discriminated union variant in SkillSourceConfig for filesystem-based skill discovery
    - SHA-1 content hash for idempotency on local files (no commit SHA available)
    - seedCreativeGroupMembers uses INSERT OR IGNORE — safe to call multiple times
    - getRawClient() exposes LibSQL singleton for direct SQL outside drizzle context

key-files:
  created:
    - server/src/skills/content/diagram.SKILL.md
    - server/src/skills/content/icon-set.SKILL.md
    - server/src/skills/content/theme-palette.SKILL.md
    - server/src/skills/content/wallpaper.SKILL.md
    - server/src/skills/content/social-post.SKILL.md
    - server/src/skills/content/convert.SKILL.md
    - server/src/skills/content/pdf-document.SKILL.md
    - server/src/skills/content/brand-kit.SKILL.md
    - server/src/skills/content/presentation.SKILL.md
    - server/src/__tests__/skill-registry-content-skills.test.ts
  modified:
    - server/src/services/skill-registry-fetcher.ts
    - server/src/services/skill-registry-db.ts
    - server/src/index.ts
    - server/src/__tests__/skill-registry-fetch.test.ts

key-decisions:
  - "SkillSourceConfig changed to discriminated union — fetchAnthropicMarketplace/fetchGitHubTree narrowed to Extract types for tsc safety"
  - "SHA-1 content hash used for local SKILL.md idempotency — no Git commit SHA available for local files"
  - "seedCreativeGroupMembers does NOT run inside getSkillRegistryDb() — must run after fetchAll so skill rows exist first"
  - "getRawClient() exported for test access — tests need raw SQL for skill_group_members queries"
  - "pendingSkillGroups reconciler merged into skill registry init block — guarantees Creative group is seeded before reconciliation"
  - "skill-registry-fetch.test.ts Test 7 updated to expect 4 BUILT_IN_SOURCES — auto-fixed to reflect new local source"

patterns-established:
  - "local-nexus-content pattern: filesystem skill source reads .SKILL.md files, derives slug from filename sans extension"
  - "Content hash idempotency: SHA-1 of file content serves as version identifier for local files"

requirements-completed: [SKILL-01, SKILL-02, SKILL-03]

# Metrics
duration: 3min
completed: 2026-04-04
---

# Phase 45 Plan 01: Content-as-Skills Summary

**9 content generators registered as installable Nexus skills via local-nexus-content source type, with Creative group seeded and startup sequence unified**

## Performance

- **Duration:** ~3 min
- **Started:** 2026-04-04T23:51:00Z
- **Completed:** 2026-04-04T23:54:15Z
- **Tasks:** 2
- **Files modified:** 14

## Accomplishments

- Authored 9 SKILL.md files (diagram, icon-set, theme-palette, wallpaper, social-post, convert, pdf-document, brand-kit, presentation) with valid YAML frontmatter, jobType usage docs, and output sections
- Extended skill-registry-fetcher.ts with local-nexus-content source type: discriminated union SkillSourceConfig, fetchLocalNexusContent private handler, nexus-content entry in BUILT_IN_SOURCES
- Added seedCreativeGroupMembers() and getRawClient() to skill-registry-db.ts; merged skill registry init and pendingSkillGroups reconciler into a single sequential startup block ensuring correct ordering

## Task Commits

1. **Task 1: Author 9 SKILL.md files and extend fetcher with local-nexus-content source** - `5138572d` (feat)
2. **Task 2: Seed Creative group members and wire startup sequence** - `98f0b8f8` (feat)

## Files Created/Modified

- `server/src/skills/content/diagram.SKILL.md` - Diagram generation skill with Mermaid jobType docs
- `server/src/skills/content/icon-set.SKILL.md` - SVG icon set generation skill docs
- `server/src/skills/content/theme-palette.SKILL.md` - OKLCH theme palette generation skill docs
- `server/src/skills/content/wallpaper.SKILL.md` - Desktop wallpaper generation skill docs
- `server/src/skills/content/social-post.SKILL.md` - Social media post generation skill docs
- `server/src/skills/content/convert.SKILL.md` - Format conversion skill docs
- `server/src/skills/content/pdf-document.SKILL.md` - PDF document generation skill docs
- `server/src/skills/content/brand-kit.SKILL.md` - Brand identity kit generation skill docs
- `server/src/skills/content/presentation.SKILL.md` - Video presentation generation skill docs
- `server/src/services/skill-registry-fetcher.ts` - Added local-nexus-content source type and handler
- `server/src/services/skill-registry-db.ts` - Added getRawClient(), seedCreativeGroupMembers(), _client singleton
- `server/src/index.ts` - Unified startup block with correct sequence
- `server/src/__tests__/skill-registry-content-skills.test.ts` - 9 tests for SKILL.md files, fetch handler, Creative group
- `server/src/__tests__/skill-registry-fetch.test.ts` - Updated Test 7 to expect 4 BUILT_IN_SOURCES

## Decisions Made

- SkillSourceConfig changed from flat type to discriminated union — required narrowing fetchAnthropicMarketplace/fetchGitHubTree to Extract types to avoid TypeScript access errors on local-nexus-content variant
- SHA-1 of file content used as version identifier for local SKILL.md files — no Git commit SHA available; provides idempotency across server restarts
- seedCreativeGroupMembers() separated from getSkillRegistryDb() initialization — must run after fetchAll() so the skills rows exist for foreign key constraints; wired sequentially in index.ts
- getRawClient() exported to give tests direct SQL access for querying skill_group_members table
- pendingSkillGroups reconciler moved inside the skill registry init block — eliminates race where reconciler could run before Creative group was seeded, causing missed group assignments

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 1 - Bug] Updated skill-registry-fetch.test.ts Test 7 to expect 4 BUILT_IN_SOURCES**
- **Found during:** Task 1 (extending fetcher)
- **Issue:** Existing test asserted `toHaveLength(3)` and `type` to match remote-only regex — both failed after adding nexus-content local source
- **Fix:** Updated count to 4, added nexus-content to expected IDs, made type check conditional on non-local sources
- **Files modified:** server/src/__tests__/skill-registry-fetch.test.ts
- **Verification:** All 7 existing fetch tests pass after update
- **Committed in:** 5138572d (Task 1 commit)

**2. [Rule 1 - Bug] Narrowed fetchAnthropicMarketplace/fetchGitHubTree parameter types**
- **Found during:** Task 2 (tsc check)
- **Issue:** Converting SkillSourceConfig to discriminated union caused tsc errors — functions accessed `.owner`, `.repo`, `.ref` which don't exist on local-nexus-content variant
- **Fix:** Changed parameter types to `Extract<SkillSourceConfig, { type: "anthropic-marketplace" }>` and `Extract<SkillSourceConfig, { type: "github-tree" }>` respectively
- **Files modified:** server/src/services/skill-registry-fetcher.ts
- **Verification:** `npx tsc --noEmit` exits 0
- **Committed in:** 98f0b8f8 (Task 2 commit)

---

**Total deviations:** 2 auto-fixed (2 Rule 1 bugs)
**Impact on plan:** Both auto-fixes required for correctness. No scope creep.

## Issues Encountered

None — plan executed cleanly with 2 small tsc/test fixes applied automatically.

## Known Stubs

None — all 9 SKILL.md files contain complete documentation with jobType, input fields, and output descriptions. The skills point to fully-implemented renderers from Phases 41-44.

## Next Phase Readiness

Phase 45 is the final phase of milestone v1.7. All content generators are now registered as installable Nexus skills discoverable by agents. The Creative group is seeded with all 9 skill IDs and the startup sequence ensures agents with `pendingSkillGroups: ["Creative"]` receive their skill group assignments.

---
*Phase: 45-content-as-skills*
*Completed: 2026-04-04*

## Self-Check: PASSED

- FOUND: server/src/skills/content/diagram.SKILL.md
- FOUND: server/src/skills/content/presentation.SKILL.md
- FOUND: server/src/services/skill-registry-fetcher.ts
- FOUND: server/src/services/skill-registry-db.ts
- FOUND: server/src/__tests__/skill-registry-content-skills.test.ts
- FOUND: .planning/phases/45-content-as-skills/45-01-SUMMARY.md
- COMMIT 5138572d: feat(45-01): author 9 content SKILL.md files and extend fetcher with local-nexus-content source
- COMMIT 98f0b8f8: feat(45-01): seed Creative group members and wire unified startup sequence
