{"id":"process-builder","name":"process-builder","summary":"SDKパターン、適切な構造、ベストプラクティスに従って新しいベビーシッターのプロセス定義をスキャフォールドします。","body":"# Process Builder\n\nCreate new process definitions for the babysitter event-sourced orchestration framework.\n\n## Quick Reference\n\n```\nProcesses live in: library/\n├── methodologies/          # Reusable development approaches (TDD, BDD, Scrum, etc.)\n│   └── [name]/\n│       ├── README.md       # Documentation\n│       ├── [name].js       # Main process\n│       └── examples/       # Sample inputs\n│\n└── specializations/        # Domain-specific processes\n    ├── [category]/         # Engineering specializations (direct children)\n    │   └── [process].js\n    └── domains/\n        └── [domain]/       # Business, Science, Social Sciences\n            └── [spec]/\n                ├── README.md\n                ├── references.md\n                ├── processes-backlog.md\n                └── [process].js\n```\n\n## 3-Phase Workflow\n\n### Phase 1: Research & Documentation\n\nCreate foundational documentation:\n\n```bash\n# Check existing specializations\nls library/specializations/\n\n# Check methodologies\nls library/methodologies/\n```\n\n**Create:**\n- `README.md` - Overview, roles, goals, use cases, common flows\n- `references.md` - External references, best practices, links to sources\n\n### Phase 2: Identify Processes\n\nCreate `processes-backlog.md` with identified processes:\n\n```markdown\n# Processes Backlog - [Specialization Name]\n\n## Identified Processes\n\n- [ ] **process-name** - Short description of what this process accomplishes\n  - Reference: [Link to methodology or standard]\n  - Inputs: list key inputs\n  - Outputs: list key outputs\n\n- [ ] **another-process** - Description\n  ...\n```\n\n### Phase 3: Create Process Files\n\nCreate `.js` process files following SDK patterns (see below).\n\n---\n\n## Process File Structure\n\nEvery process file follows this pattern:\n\n```javascript\n/**\n * @process [category]/[process-name]\n * @description Clear description of what the process accomplishes end-to-end\n * @inputs { inputName: type, optionalInput?: type }\n * @outputs { success: boolean, outputName: type, artifacts: array }\n *\n * @graph\n *   domains: [domain:software-engineering]\n *   skillAreas: [skill-area:your-skill-area]\n *   topics: [topic:your-topic]\n *   roles: [role:your-role]\n *   workflows: [workflow:your-workflow]\n *\n * @example\n * const result = await orchestrate('[category]/[process-name]', {\n *   inputName: 'value',\n *   optionalInput: 'optional-value'\n * });\n *\n * @references\n * - Book: \"Relevant Book Title\" by Author\n * - Article: [Title](https://link)\n * - Standard: ISO/IEEE reference\n */\n\nimport { defineTask } from '@a5c-ai/babysitter-sdk';\n\n/**\n * [Process Name] Process\n *\n * Methodology: Brief description of the approach\n *\n * Phases:\n * 1. Phase Name - What happens\n * 2. Phase Name - What happens\n * ...\n *\n * Benefits:\n * - Benefit 1\n * - Benefit 2\n *\n * @param {Object} inputs - Process inputs\n * @param {string} inputs.inputName - Description of input\n * @param {Object} ctx - Process context (see SDK)\n * @returns {Promise<Object>} Process result\n */\nexport async function process(inputs, ctx) {\n  const {\n    inputName,\n    optionalInput = 'default-value',\n    // ... destructure with defaults\n  } = inputs;\n\n  const artifacts = [];\n\n  // ============================================================================\n  // PHASE 1: [PHASE NAME]\n  // ============================================================================\n\n  ctx.log?.('info', 'Starting Phase 1...');\n\n  const phase1Result = await ctx.task(someTask, {\n    // task inputs\n  });\n\n  artifacts.push(...(phase1Result.artifacts || []));\n\n  // Breakpoint for human review (when needed)\n  await ctx.breakpoint({\n    question: 'Review the results and approve to continue?',\n    title: 'Phase 1 Review',\n    context: {\n      runId: ctx.runId,\n      files: [\n        { path: 'artifacts/output.md', format: 'markdown', label: 'Output' }\n      ]\n    }\n  });\n\n  // ============================================================================\n  // PHASE 2: [PHASE NAME] - Parallel Execution Example\n  // ============================================================================\n\n  const [result1, result2, result3] = await ctx.parallel.all([\n    () => ctx.task(task1, { /* args */ }),\n    () => ctx.task(task2, { /* args */ }),\n    () => ctx.task(task3, { /* args */ })\n  ]);\n\n  // ============================================================================\n  // PHASE 3: [ITERATION EXAMPLE]\n  // ============================================================================\n\n  let iteration = 0;\n  let targetMet = false;\n\n  while (!targetMet && iteration < maxIterations) {\n    iteration++;\n\n    const iterResult = await ctx.task(iterativeTask, {\n      iteration,\n      previousResults: /* ... */\n    });\n\n    targetMet = iterResult.meetsTarget;\n\n    if (!targetMet && iteration % 3 === 0) {\n      // Periodic checkpoint\n      await ctx.breakpoint({\n        question: `Iteration ${iteration}: Target not met. Continue?`,\n        title: 'Progress Checkpoint',\n        context: { /* ... */ }\n      });\n    }\n  }\n\n  // ============================================================================\n  // COMPLETION\n  // ============================================================================\n\n  return {\n    success: targetMet,\n    iterations: iteration,\n    artifacts,\n    // ... other outputs matching @outputs\n  };\n}\n\n// ============================================================================\n// TASK DEFINITIONS\n// ============================================================================\n\n/**\n * Task: [Task Name]\n * Purpose: What this task accomplishes\n */\nconst someTask = defineTask({\n  name: 'task-name',\n  description: 'What this task does',\n\n  // Task definition - executed externally by orchestrator\n  // This returns a TaskDef that describes HOW to run the task\n\n  inputs: {\n    inputName: { type: 'string', required: true },\n    optionalInput: { type: 'number', default: 10 }\n  },\n\n  outputs: {\n    result: { type: 'object' },\n    artifacts: { type: 'array' }\n  },\n\n  async run(inputs, taskCtx) {\n    const effectId = taskCtx.effectId;\n\n    return {\n      kind: 'node',  // or 'agent', 'skill', 'shell', 'breakpoint'\n      title: `Task: ${inputs.inputName}`,\n      node: {\n        entry: 'scripts/task-runner.js',\n        args: ['--input', inputs.inputName, '--effect-id', effectId]\n      },\n      io: {\n        inputJsonPath: `tasks/${effectId}/input.json`,\n        outputJsonPath: `tasks/${effectId}/result.json`\n      },\n      labels: ['category', 'subcategory']\n    };\n  }\n});\n```\n\n---\n\n## SDK Context API Reference\n\nThe `ctx` object provides these intrinsics:\n\n| Method | Purpose | Behavior |\n|--------|---------|----------|\n| `ctx.task(taskDef, args, opts?)` | Execute a task | Returns result or throws typed exception |\n| `ctx.breakpoint(payload)` | Human approval gate | Pauses until approved via human |\n| `ctx.sleepUntil(isoOrEpochMs)` | Time-based gate | Pauses until specified time |\n| `ctx.parallel.all([...thunks])` | Parallel execution | Runs independent tasks concurrently |\n| `ctx.parallel.map(items, fn)` | Parallel map | Maps items through task function |\n| `ctx.now()` | Deterministic time | Returns current Date (or provided time) |\n| `ctx.log?.(level, msg, data?)` | Logging | Optional logging helper |\n| `ctx.runId` | Run identifier | Current run's unique ID |\n\n### Task Kinds\n\n| Kind | Use Case | Executor |\n|------|----------|----------|\n| `node` | Scripts, builds, tests | Node.js process |\n| `agent` | LLM-powered analysis, generation | Claude Code agent |\n| `skill` | Claude Code skills | Skill invocation |\n| `shell` | System commands | Shell execution |\n| `breakpoint` | Human approval | Breakpoints UI/service |\n| `sleep` | Time gates | Orchestrator scheduling |\n| `orchestrator_task` | Internal orchestrator work | Self-routed |\n\n---\n\n## Breakpoint Patterns\n\n### Basic Approval Gate\n\n```javascript\nawait ctx.breakpoint({\n  question: 'Approve to continue?',\n  title: 'Checkpoint',\n  context: { runId: ctx.runId }\n});\n```\n\n### With File References (for UI display)\n\n```javascript\nawait ctx.breakpoint({\n  question: 'Review the generated specification. Does it meet requirements?',\n  title: 'Specification Review',\n  context: {\n    runId: ctx.runId,\n    files: [\n      { path: 'artifacts/spec.md', format: 'markdown', label: 'Specification' },\n      { path: 'artifacts/spec.json', format: 'json', label: 'JSON Schema' },\n      { path: 'src/implementation.ts', format: 'code', language: 'typescript', label: 'Implementation' }\n    ]\n  }\n});\n```\n\n### Conditional Breakpoint\n\n```javascript\nif (qualityScore < targetScore) {\n  await ctx.breakpoint({\n    question: `Quality score ${qualityScore} is below target ${targetScore}. Continue iterating or accept current result?`,\n    title: 'Quality Gate',\n    context: {\n      runId: ctx.runId,\n      data: { qualityScore, targetScore, iteration }\n    }\n  });\n}\n```\n\n---\n\n## Common Patterns\n\n### Quality Convergence Loop\n\n```javascript\nlet quality = 0;\nlet iteration = 0;\nconst targetQuality = inputs.targetQuality || 85;\nconst maxIterations = inputs.maxIterations || 10;\n\nwhile (quality < targetQuality && iteration < maxIterations) {\n  iteration++;\n  ctx.log?.('info', `Iteration ${iteration}/${maxIterations}`);\n\n  // Execute improvement tasks\n  const improvement = await ctx.task(improveTask, { iteration });\n\n  // Score quality (parallel checks)\n  const [coverage, lint, security, tests] = await ctx.parallel.all([\n    () => ctx.task(coverageTask, {}),\n    () => ctx.task(lintTask, {}),\n    () => ctx.task(securityTask, {}),\n    () => ctx.task(runTestsTask, {})\n  ]);\n\n  // Agent scores overall quality\n  const score = await ctx.task(agentScoringTask, {\n    coverage, lint, security, tests, iteration\n  });\n\n  quality = score.overall;\n  ctx.log?.('info', `Quality: ${quality}/${targetQuality}`);\n\n  if (quality >= targetQuality) {\n    ctx.log?.('info', 'Quality target achieved!');\n    break;\n  }\n}\n\nreturn {\n  success: quality >= targetQuality,\n  quality,\n  iterations: iteration\n};\n```\n\n### Phased Workflow with Reviews\n\n```javascript\n// Phase 1: Research\nconst research = await ctx.task(researchTask, { topic: inputs.topic });\n\nawait ctx.breakpoint({\n  question: 'Review research findings before proceeding to planning.',\n  title: 'Research Review',\n  context: { runId: ctx.runId }\n});\n\n// Phase 2: Planning\nconst plan = await ctx.task(planningTask, { research });\n\nawait ctx.breakpoint({\n  question: 'Review plan before implementation.',\n  title: 'Plan Review',\n  context: { runId: ctx.runId }\n});\n\n// Phase 3: Implementation\nconst implementation = await ctx.task(implementTask, { plan });\n\n// Phase 4: Verification\nconst verification = await ctx.task(verifyTask, { implementation, plan });\n\nawait ctx.breakpoint({\n  question: 'Final review before completion.',\n  title: 'Final Approval',\n  context: { runId: ctx.runId }\n});\n\nreturn { success: verification.passed, plan, implementation };\n```\n\n### Parallel Fan-out with Aggregation\n\n```javascript\n// Fan out to multiple parallel analyses\nconst analyses = await ctx.parallel.map(components, component =>\n  ctx.task(analyzeTask, { component }, { label: `analyze:${component.name}` })\n);\n\n// Aggregate results\nconst aggregated = await ctx.task(aggregateTask, { analyses });\n\nreturn { analyses, summary: aggregated.summary };\n```\n\n---\n\n## Testing Processes\n\n### CLI Commands\n\n```bash\n# Create a new run\nbabysitter run:create \\\n  --process-id methodologies/my-process \\\n  --entry ./library/methodologies/my-process.js#process \\\n  --inputs ./test-inputs.json \\\n  --json\n\n# Iterate the run\nbabysitter run:iterate .a5c/runs/<runId> --json\n\n# List pending tasks\nbabysitter task:list .a5c/runs/<runId> --pending --json\n\n# Post a task result\nbabysitter task:post .a5c/runs/<runId> <effectId> \\\n  --status ok \\\n  --value ./result.json\n\n# Check run status\nbabysitter run:status .a5c/runs/<runId>\n\n# View events\nbabysitter run:events .a5c/runs/<runId> --limit 20 --reverse\n```\n\n### Sample Test Input File\n\n```json\n{\n  \"feature\": \"User authentication with JWT\",\n  \"acceptanceCriteria\": [\n    \"Users can register with email and password\",\n    \"Users can login and receive a JWT token\",\n    \"Invalid credentials are rejected\"\n  ],\n  \"testFramework\": \"jest\",\n  \"targetQuality\": 85,\n  \"maxIterations\": 5\n}\n```\n\n---\n\n## Process Builder Workflow\n\n### 1. Gather Requirements\n\nAsk the user:\n\n| Question | Purpose |\n|----------|---------|\n| **Domain/Category** | Determines directory location |\n| **Process Name** | kebab-case identifier |\n| **Goal** | What should the process accomplish? |\n| **Inputs** | What data does the process need? |\n| **Outputs** | What artifacts/results does it produce? |\n| **Phases** | What are the major steps? |\n| **Quality Gates** | Where should humans review? |\n| **Iteration Strategy** | Fixed phases vs. convergence loop? |\n\n### 2. Research Similar Processes\n\n```bash\n# Find similar processes\nls library/methodologies/\nls library/specializations/\n\n# Read similar process for patterns\ncat library/methodologies/atdd-tdd/atdd-tdd.js | head -200\n\n# Check methodology README structure\ncat library/methodologies/atdd-tdd/README.md\n```\n\n### 3. Check Methodologies Backlog\n\n```bash\ncat library/methodologies/backlog.md\n```\n\n### 4. Create the Process\n\n**For Methodologies:**\n1. Create `methodologies/[name]/README.md` (comprehensive documentation)\n2. Create `methodologies/[name]/[name].js` (process implementation)\n3. Create `methodologies/[name]/examples/` (sample inputs)\n\n**For Specializations:**\n1. If domain-specific: `specializations/domains/[domain]/[spec]/`\n2. If engineering: `specializations/[category]/[process].js`\n3. Create README.md, references.md, processes-backlog.md first\n4. Then create individual process.js files\n\n### 5. Validate Structure\n\nChecklist:\n- [ ] JSDoc header with @process, @description, @inputs, @outputs, @example, @references\n- [ ] `@graph` block with relevant atlas node IDs (at minimum one domain)\n- [ ] Import from `@a5c-ai/babysitter-sdk`\n- [ ] Main `export async function process(inputs, ctx)`\n- [ ] Input destructuring with defaults\n- [ ] Clear phase comments (`// === PHASE N: NAME ===`)\n- [ ] Logging via `ctx.log?.('info', message)`\n- [ ] Tasks via `ctx.task(taskDef, inputs)`\n- [ ] Breakpoints at key decision points\n- [ ] Artifact collection throughout\n- [ ] Return object matches @outputs schema\n\n---\n\n## Examples by Type\n\n### Methodology Process (atdd-tdd style)\n\n```javascript\n/**\n * @process methodologies/my-methodology\n * @description My development methodology with quality convergence\n * @inputs { feature: string, targetQuality?: number }\n * @outputs { success: boolean, quality: number, artifacts: array }\n */\nexport async function process(inputs, ctx) {\n  const { feature, targetQuality = 85 } = inputs;\n  // ... implementation\n}\n```\n\n### Specialization Process (game-development style)\n\n```javascript\n/**\n * @process specializations/game-development/core-mechanics-prototyping\n * @description Prototype and validate core gameplay mechanics through iteration\n * @inputs { prototypeName: string, mechanicsToTest: array, engine?: string }\n * @outputs { success: boolean, mechanicsValidated: array, playtestResults: object }\n */\nexport async function process(inputs, ctx) {\n  const { prototypeName, mechanicsToTest, engine = 'Unity' } = inputs;\n  // ... implementation\n}\n```\n\n### Domain Process (science/research style)\n\n```javascript\n/**\n * @process specializations/domains/science/bioinformatics/sequence-analysis\n * @description Analyze genomic sequences using standard bioinformatics workflows\n * @inputs { sequences: array, analysisType: string, referenceGenome?: string }\n * @outputs { success: boolean, alignments: array, variants: array, report: object }\n */\nexport async function process(inputs, ctx) {\n  const { sequences, analysisType, referenceGenome = 'GRCh38' } = inputs;\n  // ... implementation\n}\n```\n\n---\n\n## Atlas Graph Metadata\n\nEvery generated process file MUST include a `@graph` JSDoc block in its file header comment alongside the standard `@process`, `@description`, `@inputs`, and `@outputs` tags.\n\n### Format\n\n```javascript\n/**\n * @process specializations/my-domain/my-process\n * @description ...\n * @inputs { ... }\n * @outputs { ... }\n *\n * @graph\n *   domains: [domain:software-engineering, domain:devops]\n *   skillAreas: [skill-area:caching-strategies]\n *   topics: [topic:microservices, topic:event-sourcing]\n *   roles: [role:backend-engineer, role:sre]\n *   workflows: [workflow:code-review]\n */\n```\n\n### How to choose node IDs\n\nRead the atlas graph domain directory (`packages/atlas/graph/domain/`) to find valid node IDs. The directory contains YAML files grouped by category:\n\n- `domains/` — high-level domain nodes (e.g. `domain:software-engineering`, `domain:devops`, `domain:data-engineering`)\n- `skill-areas/` — specific skill area nodes\n- `topics/` — granular topic nodes\n- `roles/` — role nodes (engineers, practitioners, researchers)\n- `workflows/` — workflow nodes\n\nPick **2–4 edges** that genuinely relate to the process. Do not guess IDs — read the actual YAML files to find valid ones. At minimum, **every process must reference at least one `domain:` node**.\n\n### Why this matters\n\nThis metadata connects the process to the atlas knowledge graph. A pre-build generator script parses the `@graph` block and creates graph nodes and edges for discoverability. Processes without this block will not appear in graph-based search results or recommendations.\n\n---\n\n## Resources\n\n- **SDK Reference**: `library/reference/sdk.md`\n- **Methodology Backlog**: `library/methodologies/backlog.md`\n- **Specializations Backlog**: `library/specializations/backlog.md`\n- **Example: ATDD/TDD**: `library/methodologies/atdd-tdd/`\n- **Example: Spec-Driven**: `library/methodologies/spec-driven-development.js`\n- **README**: Root `README.md` for full framework documentation","author":"@a5c-ai","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/a5c-ai/babysitter/tree/main/.claude/skills/process-builder","license":"MIT","category":"research","lang":"en","tokens":4246,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}