Topics Refactor Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Reduce setup boilerplate in almanac topics mutating commands while preserving behavior.
Architecture: Keep one command module for the topics command group. Extract only the repeated fresh-workspace setup path used by mutating commands: resolve wiki root, refresh index, load topics.yaml, and open index.db. Do not split each verb into separate files yet.
Tech Stack: TypeScript, better-sqlite3, Vitest.
Task 1: Extract Fresh Topics Workspace#
Files:
- Modify:
src/commands/topics.ts
Steps:
- Add a
TopicsWorkspaceinterface. - Add
openFreshTopicsWorkspace(options)for mutating commands. - Add
closeWorkspace(workspace)to centralize DB cleanup. - Replace repeated setup in
create,link,rename,delete, anddescribe.
Task 2: Verify Behavior#
Commands:
npm test -- test/topics.test.ts test/tag.test.tsnpm testnpm run lintnpm run build
Expected: No output or JSON semantics change; all tests and build pass.