---
phase: 16-frontend-scaffold
plan: 02
type: execute
wave: 1
depends_on: []
files_modified: [packages/shared/package.json, packages/shared/tsconfig.json, packages/shared/src/index.ts, packages/shared/src/trpc.ts, packages/shared/src/types.ts, package.json, src/trpc/router.ts]
autonomous: true
---

<objective>
Export shared types (AppRouter, DB entity types) from a shared package so the frontend can consume them.

Purpose: The frontend needs AppRouter type for tRPC client type inference, and DB entity types (Initiative, Phase, Task, Agent, Message) for component props. Creating a shared package avoids import path gymnastics between backend and frontend.
Output: `packages/shared/` package exporting AppRouter and entity types.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md

# Existing types to export
@src/trpc/router.ts
@src/db/schema.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Create shared types package</name>
  <files>packages/shared/package.json, packages/shared/tsconfig.json, packages/shared/src/index.ts, packages/shared/src/trpc.ts, packages/shared/src/types.ts, package.json</files>
  <action>
1. Create `packages/shared/` directory.

2. Create `packages/shared/package.json`:
   - name: `@codewalk-district/shared`
   - type: module
   - main: `./src/index.ts` (no build step — consumed via TypeScript project references)
   - types: `./src/index.ts`
   - exports: `{ ".": "./src/index.ts" }`

3. Create `packages/shared/tsconfig.json`:
   - Extends nothing (standalone)
   - compilerOptions: target ES2022, module NodeNext, moduleResolution NodeNext, strict, declaration true, composite true, outDir dist
   - include: `["src"]`

4. Create `packages/shared/src/trpc.ts`:
   - Re-export the AppRouter type from the backend:
   ```typescript
   export type { AppRouter } from '../../../src/trpc/router.js';
   ```
   This uses relative path since we're in the same git repo. The frontend will import `AppRouter` from `@codewalk-district/shared`.

5. Create `packages/shared/src/types.ts`:
   - Re-export entity types the frontend needs:
   ```typescript
   export type { Initiative, Phase, Plan, Task, Agent, Message } from '../../../src/db/schema.js';
   ```
   These are the Drizzle InferSelectModel types (read-only shapes).

6. Create `packages/shared/src/index.ts`:
   - Barrel export:
   ```typescript
   export type { AppRouter } from './trpc.js';
   export type { Initiative, Phase, Plan, Task, Agent, Message } from './types.js';
   ```

7. Add `packages/shared` to root `package.json` workspaces array (should already include `"packages/*"` from Plan 01, but verify).

8. Run `npm install` from root to link the shared package.

NOTE: This package exports ONLY types (no runtime code). It exists solely so the frontend can `import type { AppRouter } from '@codewalk-district/shared'` without reaching into backend internals.
  </action>
  <verify>
cd packages/shared && npx tsc --noEmit succeeds (types resolve correctly).
From packages/web, importing `type { AppRouter } from '@codewalk-district/shared'` should resolve (test with a scratch file if needed, or just verify tsc).
  </verify>
  <done>AppRouter and entity types importable from @codewalk-district/shared. No build step needed — TypeScript resolves directly.</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `packages/shared/` exists with package.json, tsconfig.json, and src/
- [ ] TypeScript compiles `packages/shared/` without errors
- [ ] AppRouter type re-exported correctly
- [ ] Entity types (Initiative, Phase, Task, etc.) re-exported correctly
</verification>

<success_criteria>

- @codewalk-district/shared package exists and resolves
- AppRouter type accessible to frontend consumers
- Entity types accessible to frontend consumers
- No runtime dependencies — types only
  </success_criteria>

<output>
After completion, create `.planning/phases/16-frontend-scaffold/16-02-SUMMARY.md`
</output>
