-
-
Save timblaktu/24130de0aa33eee93e500f3f7bcc19d3 to your computer and use it in GitHub Desktop.
An example of what my agent will do. Note that it queries db itself, then makes plan. Also note that after the plan, a hook instructs it in how to parallelize the plan. It then uses custom implementor agents to execute the plan. This is a pretty sizable feature, and it's getting one-shot perfectly, and quickly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I'll help you implement a writing quirks feature that generates unique stylistic elements before | |
| outline creation. Let me first understand the current structure and then create a plan. | |
| ⏺ Let me investigate the current codebase structure to understand how outline and plot generation | |
| work. | |
| ⏺ Read(src/generation/outline/newOutline.ts) | |
| ⎿ Read 237 lines (ctrl+r to expand) | |
| ⏺ sql - describe-table (MCP)(tableName: "sequences", includeConstraints: true, includeSampleRows: true) | |
| ⎿ Error: MCP tool "describe-table" response (30697 tokens) exceeds maximum allowed tokens (25000). | |
| Please use pagination, filtering, or limit parameters to reduce the response size. | |
| ⏺ Read(src/generation/plot/plotPoint.ts) | |
| ⎿ Read 427 lines (ctrl+r to expand) | |
| ⏺ Search(pattern: "src/generation/**/*.ts") | |
| ⎿ Found 10 files (ctrl+r to expand) | |
| ⎿ src/generation/CLAUDE.md | |
| ⏺ Let me check the database schema to understand where to store the writing quirks. | |
| ⏺ sql - describe-table (MCP)(tableName: "sequences", includeConstraints: false, includeSampleRows: | |
| false, includeRlsPolicies: false, includeTriggers: false) | |
| ⎿ ## sequences | |
| | Column | Type | Nullable | Default | | |
| … +29 lines (ctrl+r to expand) | |
| ⏺ Read(src/generation/constants.ts) | |
| ⎿ Read 58 lines (ctrl+r to expand) | |
| ⏺ Read(src/lib/types.ts) | |
| ⎿ Read 42 lines (ctrl+r to expand) | |
| ⏺ Let me check the job processor to understand how the generation flow works. | |
| ⏺ Read(src/job-processor.ts) | |
| ⎿ Error reading file | |
| ⏺ Search(pattern: "src/**/job*.ts") | |
| ⎿ Found 2 files (ctrl+r to expand) | |
| ⏺ Search(pattern: "src/**/processor*.ts") | |
| ⎿ Found 0 files | |
| ⏺ Read(src/job-processor-v2.ts) | |
| ⎿ Read 150 lines (ctrl+r to expand) | |
| ⏺ Now let me understand the outline processor to see how outlines are currently generated. | |
| ⏺ Read(src/services/outline-processor.ts) | |
| ⎿ Read 111 lines (ctrl+r to expand) | |
| ⏺ Based on my investigation, I now have a comprehensive understanding of the codebase. Let me present | |
| my plan for implementing the writing quirks feature. | |
| ⎿ User rejected Claude's plan: | |
| ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ | |
| │ Writing Quirks Implementation Plan │ | |
| │ │ | |
| │ Overview │ | |
| │ │ | |
| │ Add a writing quirks generation system that creates unique stylistic elements before outline │ | |
| │ generation. One quirk will be randomly selected and applied throughout the story generation │ | |
| │ process. │ | |
| │ │ | |
| │ Implementation Steps │ | |
| │ │ | |
| │ 1. Create Writing Quirks Module (src/generation/quirks/writingQuirks.ts) │ | |
| │ │ | |
| │ - Generate 4 writing quirk options using AI (generateObject with Zod schema) │ | |
| │ - Each quirk in format: "Title - Description" │ | |
| │ - Examples: "Occasional Flashbacks - 2-3 sentence memories in italics", "Stream of │ | |
| │ Consciousness - Internal monologues revealing character thoughts" │ | |
| │ - Use OpenRouter/Gemini 2.5 Pro with structured output │ | |
| │ │ | |
| │ 2. Update Database Schema │ | |
| │ │ | |
| │ - Add writing_quirk column to sequences table (text type) │ | |
| │ - Create migration: supabase migration new add_writing_quirk │ | |
| │ - Push migration to remote database │ | |
| │ │ | |
| │ 3. Update Type Definitions │ | |
| │ │ | |
| │ - Add writing_quirk?: string to Sequence type in src/lib/types.ts │ | |
| │ - Update UserPrompt interface if needed │ | |
| │ │ | |
| │ 4. Integrate into Outline Generation Flow │ | |
| │ │ | |
| │ - Modify OutlineProcessor.generateNewOutline() to: │ | |
| │ a. Generate writing quirks before outline │ | |
| │ b. Select one quirk randomly │ | |
| │ c. Save to sequence's writing_quirk field │ | |
| │ d. Pass quirk to outline generation │ | |
| │ - Update newOutline.ts system prompt to include writing quirk │ | |
| │ - Update regenerateOutline.ts to use existing quirk from sequence │ | |
| │ │ | |
| │ 5. Integrate into Plot Point Generation │ | |
| │ │ | |
| │ - Modify plotPoint.ts system prompt to include writing quirk │ | |
| │ - Fetch quirk from sequence when generating plot points │ | |
| │ - Add quirk to author style guidelines │ | |
| │ │ | |
| │ 6. Update Job Processor │ | |
| │ │ | |
| │ - Ensure writing quirk is fetched with sequence data │ | |
| │ - Pass quirk through generation pipeline │ | |
| │ │ | |
| │ Files to Create/Modify │ | |
| │ │ | |
| │ New Files: │ | |
| │ - src/generation/quirks/writingQuirks.ts - Quirk generation logic │ | |
| │ - Migration file for database schema │ | |
| │ │ | |
| │ Modified Files: │ | |
| │ - src/lib/types.ts - Add writing_quirk field │ | |
| │ - src/services/outline-processor.ts - Generate quirks before outline │ | |
| │ - src/generation/outline/newOutline.ts - Include quirk in system prompt │ | |
| │ - src/generation/outline/regenerateOutline.ts - Use existing quirk │ | |
| │ - src/generation/plot/plotPoint.ts - Include quirk in generation │ | |
| │ - src/services/sequence-service.ts - Handle quirk persistence │ | |
| │ │ | |
| │ Technical Details │ | |
| │ │ | |
| │ Quirk Generation Schema (Zod): │ | |
| │ │ | |
| │ const WritingQuirksSchema = z.object({ │ | |
| │ quirks: z.array(z.string()).length(4) │ | |
| │ }); │ | |
| │ │ | |
| │ System Prompt Addition: │ | |
| │ │ | |
| │ <writing_style_quirk> │ | |
| │ The author has a distinctive writing quirk: ${writingQuirk} │ | |
| │ Incorporate this stylistic element naturally throughout the narrative. │ | |
| │ </writing_style_quirk> │ | |
| │ │ | |
| │ This implementation will enhance story uniqueness while maintaining existing functionality. │ | |
| ╰────────────────────────────────────────────────────────────────────────────────────────────────╯ | |
| > When updating teh db, just use the sql tool directly, no migration needed—just remember to run | |
| db:types again afterwards. Also, for the zod schema, make sure to include the .describe("useful 1-2 | |
| setnence description of field"). Also, that system prompt addition needs to be incorporated both into | |
| the outline generation and the plotpoint generation. | |
| ⏺ I'll update the plan to use direct SQL for the database change and include the Zod descriptions as | |
| requested. | |
| ⏺ User approved Claude's plan: | |
| ⎿ Writing Quirks Implementation Plan (Updated) | |
| Overview | |
| Add a writing quirks generation system that creates unique stylistic elements before outline | |
| generation. One quirk will be randomly selected and applied throughout the story generation | |
| process. | |
| Implementation Steps | |
| 1. Create Writing Quirks Module (src/generation/quirks/writingQuirks.ts) | |
| - Generate 4 writing quirk options using AI (generateObject with Zod schema) | |
| - Each quirk in format: "Title - Description" | |
| - Examples: "Occasional Flashbacks - 2-3 sentence memories in italics", "Stream of Consciousness | |
| - Internal monologues revealing character thoughts" | |
| - Use OpenRouter/Gemini 2.5 Pro with structured output | |
| Zod Schema with descriptions: | |
| const WritingQuirksSchema = z.object({ | |
| quirks: z.array(z.string() | |
| .describe("A writing quirk in format 'Title - Description', e.g., 'Occasional Flashbacks - | |
| 2-3 sentence memories in italics'")) | |
| .length(4) | |
| .describe("Exactly 4 unique writing style quirks that could enhance the storytelling") | |
| }); | |
| 2. Update Database Schema (Direct SQL) | |
| - Use SQL tool to add writing_quirk column to sequences table | |
| - Run npm run db:types to regenerate TypeScript types | |
| - SQL: ALTER TABLE sequences ADD COLUMN writing_quirk TEXT; | |
| 3. Update Type Definitions | |
| - After db:types generation, update Sequence type in src/lib/types.ts if needed | |
| - Ensure writing_quirk field is properly typed | |
| 4. Integrate into Outline Generation Flow | |
| - Modify OutlineProcessor.generateNewOutline() to: | |
| a. Generate writing quirks before outline | |
| b. Select one quirk randomly | |
| c. Save to sequence's writing_quirk field | |
| d. Pass quirk to outline generation | |
| - Update newOutline.ts system prompt to include: | |
| <writing_style_quirk> | |
| The author has a distinctive writing quirk: ${writingQuirk} | |
| Incorporate this stylistic element naturally throughout the narrative. | |
| </writing_style_quirk> | |
| - Update regenerateOutline.ts to use existing quirk from sequence | |
| 5. Integrate into Plot Point Generation | |
| - Modify plotPoint.ts system prompt to include the same writing quirk section: | |
| <writing_style_quirk> | |
| The author has a distinctive writing quirk: ${writingQuirk} | |
| Incorporate this stylistic element naturally throughout the narrative. | |
| </writing_style_quirk> | |
| - Fetch quirk from sequence when generating plot points | |
| - Add quirk to the system prompt between romance guidelines and avoided behavior sections | |
| 6. Update Supporting Services | |
| - SequenceService: Add method to update writing quirk | |
| - Ensure quirk is fetched with sequence data | |
| - Pass quirk through the entire generation pipeline | |
| Files to Create/Modify | |
| New Files: | |
| - src/generation/quirks/writingQuirks.ts - Quirk generation logic with Zod schema | |
| Modified Files: | |
| - Database: Direct SQL to add writing_quirk column | |
| - src/lib/types.ts - Ensure writing_quirk field after db:types | |
| - src/services/outline-processor.ts - Generate quirks before outline | |
| - src/generation/outline/newOutline.ts - Include quirk in system prompt | |
| - src/generation/outline/regenerateOutline.ts - Use existing quirk | |
| - src/generation/plot/plotPoint.ts - Include quirk in system prompt | |
| - src/services/sequence-service.ts - Handle quirk persistence | |
| - src/job-processor-v2.ts - Pass quirk through pipeline | |
| Example Writing Quirks | |
| 1. "Occasional Flashbacks - 2-3 sentence memories in italics revealing character backstory" | |
| 2. "Multiple POVs - Alternating perspectives with distinct character voices" | |
| 3. "Stream of Consciousness - Internal monologues showing unfiltered thoughts" | |
| 4. "Epistolary Elements - Letters, texts, or diary entries woven into narrative" | |
| 5. "Repetitive Motifs - Recurring phrases that evolve in meaning throughout story" | |
| 6. "Breaking Fourth Wall - Direct addresses to the reader at key moments" | |
| 7. "Fragmented Sentences - Short, punchy sentences during intense scenes" | |
| 8. "Sensory Focus - Rich descriptions emphasizing specific senses per scene" | |
| This implementation will enhance story uniqueness while maintaining existing functionality. | |
| > <post-tool-use-hook><system-reminder> | |
| **Parallelize the Plan** | |
| The initial plan has been drafted. Now, **think** to optimize its execution. | |
| 1. **Analyze Dependencies**: Critically review the list of tasks. | |
| 2. **Group for Parallelism**: Identify any tasks that are independent and can be executed | |
| concurrently. Group them into a parallel stage. | |
| 3. **Format for Parallel Execution**: Place multiple `<invoke name="Task">` calls inside a **single** | |
| `<function_calls>` block in your response, using the optimal agent for each task. | |
| 4. **Delegate Every Step**: Even stages that have just one step should be delegated to an agent, | |
| unless it is a trivial step. This avoids clogging your context window. And remember, no more than one | |
| task per agent. | |
| <example> | |
| Assistant: I will now run [list of tasks] in parallel. | |
| <function_calls> | |
| <invoke name="Task"> | |
| <parameter name="description">First parallel task...</parameter> | |
| <parameter name="prompt">Details for the first task...</parameter> | |
| </invoke> | |
| <invoke name="Task"> | |
| <parameter name="description">Second parallel task...</parameter> | |
| <parameter name="prompt">Details for the second task...</parameter> | |
| </invoke> | |
| </function_calls> | |
| I will now run [list of tasks] in parallel. | |
| ...more parallel tasks | |
| </example> | |
| Please present your analysis of parallel stages and then proceed with the first stage. Remember, you | |
| MUST delegate steps to agents. | |
| </system-reminder></post-tool-use-hook> | |
| ⏺ Let me analyze the task dependencies and identify what can be parallelized: | |
| Dependency Analysis | |
| Stage 1 (Can be done in parallel): | |
| - Create the writing quirks module with generation logic | |
| - Update the database schema directly with SQL | |
| Stage 2 (Depends on Stage 1): | |
| - Regenerate TypeScript types with npm run db:types | |
| - Update type definitions if needed | |
| Stage 3 (Can be done in parallel after Stage 2): | |
| - Integrate quirks into outline generation (newOutline.ts) | |
| - Integrate quirks into plot point generation (plotPoint.ts) | |
| - Update outline processor to generate and save quirks | |
| - Update sequence service to handle quirk persistence | |
| Stage 4 (Depends on Stage 3): | |
| - Update regenerate outline to use existing quirks | |
| - Ensure job processor passes quirks through pipeline | |
| Let me update my todo list and start with Stage 1: | |
| ⏺ I'll now execute Stage 1 tasks in parallel: | |
| ⏺ implementor(Create quirks module) | |
| ⎿ Done (9 tool uses · 35.8k tokens · 1m 32.1s) | |
| ⏺ implementor(Update database schema) | |
| ⎿ Done (2 tool uses · 17.5k tokens · 18.9s) | |
| ⏺ Excellent! Stage 1 is complete. Now let me update the todo list and proceed with Stage 2: | |
| ⏺ Now running Stage 2 - regenerating TypeScript types: | |
| ⏺ Bash(npm run db:types) | |
| ⎿ Error: Bash operation blocked by hook: | |
| - [/Users/silasrhyneer/.claude/hooks/npm-to-pnpm-warning.py]: Consider using pnpm instead of npm | |
| for better performance and disk efficiency. | |
| Suggested command: pnpm run db:types | |
| If you want to proceed with npm anyway, please confirm. | |
| ⏺ Bash(pnpm run db:types) | |
| ⎿ > [email protected] db:types /Users/silasrhyneer/Code/Smut-AI/smut-writer-worker | |
| > supabase gen types typescript --linked > src/lib/supabase/types.ts && node scripts/extract-tab | |
| les.js | |
| … +5 lines (ctrl+r to expand) | |
| ⏺ Types have been regenerated. Let me verify the writing_quirk field is in the types: | |
| ⏺ Search(pattern: "writing_quirk", path: "src/lib/supabase/types.ts", output_mode: "content") | |
| ⎿ Found 3 lines (ctrl+r to expand) | |
| ⏺ Perfect! The types have been updated. Now let me update the todo list and proceed with Stage 3 - | |
| multiple parallel integrations: | |
| ⏺ Now executing Stage 3 tasks in parallel: | |
| ⏺ implementor(Integrate quirks into newOutline) | |
| ⎿ Done (6 tool uses · 22.7k tokens · 50.9s) | |
| implementor(Integrate quirks into plotPoint) | |
| ⎿ Read(src/generation/plot/plotPoint.ts) | |
| Read 35 lines (ctrl+r to expand) | |
| +3 more tool uses | |
| implementor(Update outline processor) | |
| ⎿ Read(src/lib/types.ts) | |
| Read 42 lines (ctrl+r to expand) | |
| +8 more tool uses | |
| ⏺ implementor(Update sequence service) | |
| ⎿ Done (4 tool uses · 19.7k tokens · 51.3s) | |
| ✻ Integrating quirks into outline generation… (esc to interrupt · ctrl+t to show todos) | |
| ⎿ Next: Update regenerate outline | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment