HookStackGitHub
Back to catalogue
WorkflowTaskCreated

Enforce task naming conventions

Blocks task creation when the subject does not start with a ticket reference in the format [PREFIX-123]. Ensures every agent-created task is traceable to a project management ticket before it enters the queue.

Use cases

  • Require ticket numbers on all tasks created by agent teams (e.g. [PROJ-42])
  • Enforce consistent task naming in multi-agent CI pipelines
  • Prevent orphaned tasks with no traceability to Linear, Jira or GitHub issues

Providers & tags

Claude Code
#tasks#naming#agent-teams#traceability#conventions

settings.json fragment

{
  "hooks": {
    "TaskCreated": [
      {
        "hooks": [
          {
            "command": "node $CLAUDE_PROJECT_DIR/.claude/hooks/task-created-naming-convention.mjs",
            "type": "command"
          }
        ]
      }
    ]
  }
}

Script · .claude/hooks/task-created-naming-convention.mjs

#!/usr/bin/env node
// Impose une référence de ticket en tête du sujet d'une tâche (TaskCreated)
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';

export function run(input) {
  const subject = input.task_subject ?? '';
  if (/^\[[A-Z]+-\d+\]/.test(subject)) return null;
  return {
    exitCode: 2,
    message:
      `Task subject must start with a ticket reference, e.g. "[PROJ-123] ${subject}". ` +
      'Update the subject to include a valid ticket number.',
  };
}

/* v8 ignore next 6 */
if (process.argv[1] === fileURLToPath(import.meta.url)) {
  const input = JSON.parse(readFileSync(0, 'utf8'));
  const result = run(input);
  if (result) {
    process.stderr.write(result.message);
    process.exit(result.exitCode);
  }
}