MCPcopy Create free account
hub / github.com/Pimzino/claude-code-spec-workflow / generateTaskCommand

Function generateTaskCommand

src/task-generator.ts:190–276  ·  view source on GitHub ↗
(
  commandsDir: string,
  specName: string,
  task: ParsedTask
)

Source from the content-addressed store, hash-verified

188 * Generate a command file for a specific task
189 */
190export async function generateTaskCommand(
191 commandsDir: string,
192 specName: string,
193 task: ParsedTask
194): Promise<void> {
195 const fs = await import('fs/promises');
196 const pathModule = await import('path');
197
198 const commandFile = pathModule.join(commandsDir, `task-${task.id}.md`);
199
200 // Determine project path from commandsDir (commandsDir is typically .claude/commands/{specName})
201 const projectPath = pathModule.resolve(commandsDir, '../../..');
202
203 // Load actual content
204 const steeringContext = loadSteeringContext(projectPath);
205 const specContext = loadSpecContext(specName, projectPath);
206
207 let content = `# ${specName} - Task ${task.id}
208
209Execute task ${task.id} for the ${specName} specification.
210
211## Task Description
212${task.description}
213
214`;
215
216 // Add Code Reuse section if leverage info exists
217 if (task.leverage) {
218 content += `## Code Reuse
219**Leverage existing code**: ${task.leverage}
220
221`;
222 }
223
224 // Add Requirements section if requirements exist
225 if (task.requirements) {
226 content += `## Requirements Reference
227**Requirements**: ${task.requirements}
228
229`;
230 }
231
232 content += `## Usage
233\`\`\`
234/Task:${task.id}-${specName}
235\`\`\`
236
237## Instructions
238
239Execute with @spec-task-executor agent the following task: "${task.description}"
240
241\`\`\`
242Use the @spec-task-executor agent to implement task ${task.id}: "${task.description}" for the ${specName} specification and include all the below context.
243
244# Steering Context
245${steeringContext}
246
247# Specification Context

Callers 4

cli.tsFile · 0.90

Calls 2

loadSteeringContextFunction · 0.85
loadSpecContextFunction · 0.85

Tested by

no test coverage detected