--- kind: task slug: add-workflow-prompt-to-backlog-items title: Add workflow_prompt column to markdown_backlog_items, with inheritance plan_slug: agent-coordination epic_slug: task-as-runnable-unit status: ready priority: P2 tenant_id: global owner: unassigned cursor_todo_id: null updated_at: "2026-06-01" --- # Task summary Backlog items need a place to store a per-item agent prompt. Add a `workflow_prompt` text column to `markdown_backlog_items`, parse it from frontmatter, and define an inheritance chain (task → epic → plan → workspace default). ## Description ### Frontmatter contract Add an optional `agent_prompt:` field to the YAML frontmatter of Plan/Epic/Task templates. It's a multiline string (use `|` block scalar in YAML). Example: ```yaml agent_prompt: | You are working on a focused implementation task in a multitenant TypeScript monorepo. Read the task body in full before writing any code. Validate every external input with zod. Run pnpm lint && pnpm type-check before declaring done. ``` Update `docs/templates/{plan,epic,task}-template.md` to include the field (commented-out for tasks, since most tasks will inherit). ### Schema Add to `markdown_backlog_items`: - `workflow_prompt` text null No new index needed; this column is rarely filtered on. ### Parser In `packages/database/src/markdown-backlog/parse.ts`, extract `agent_prompt` from the parsed frontmatter into `workflow_prompt` on the upserted row. Use the existing zod schema for backlog frontmatter — extend it; don't fork. ### Inheritance helper A new function `resolveWorkflowPrompt(db, { workspaceId, backlogItemId })` that walks task → epic → plan and returns the first non-null `workflow_prompt`. If none exist, return a built-in default string (lives as a constant in `packages/database/src/markdown-backlog/`). Workspace-level overrides can come later. Don't store the resolved prompt anywhere — always compute on read. Caching is premature; this is a small lookup. ### Minimal UI Add a "Workflow prompt" section to the task detail panel (`apps/web/components/panels/object-detail.tsx` or wherever the backlog-item detail lives). Show: - "Effective prompt" — the result of `resolveWorkflowPrompt` (read-only). - "Override" — a textarea bound to the item's own `workflow_prompt`. Empty = inherit. Use a tRPC procedure `backlog.updateWorkflowPrompt({ backlogItemId, workflowPrompt })` that re-renders the panel on success. ### Anti-goals - Don't write a template engine for the prompt. Symphony uses Liquid; we don't need that yet. A plain string is fine. - Don't store prompts in `objects`. The agent flow is anchored on the markdown backlog, not the generic objects table. ## Subtasks - [ ] Extend backlog frontmatter zod schema with `agent_prompt`. - [ ] Add `workflow_prompt` column + migration. - [ ] Parse and persist in `parse.ts`. - [ ] Implement `resolveWorkflowPrompt` with the inheritance walk. - [ ] Update Plan/Epic/Task templates in `docs/templates/`. - [ ] Add UI panel section. ## Owner or assignee Unassigned ## Status ready ## Estimation M ## Acceptance criteria - [ ] A task with no override falls back to its epic's prompt; an epic with no override falls back to its plan; a plan with no override falls back to the built-in default. - [ ] Setting `agent_prompt:` in frontmatter and re-importing populates `workflow_prompt`. - [ ] UI shows effective prompt and override box. ## Links to related Epic / Plan - Epic: `./Epic-task-as-runnable-unit.md` - Plan: `../Plan-agent-coordination.md`