Validate and apply labels

From lightspeedwp/.github · View interactive version

Validate and apply labels is an AI agent skill from the GitHub repository lightspeedwp/.github. Maps branch types to labels and validates them against built-in defaults or a caller-supplied canonical set, including exactly one changelog-decision label. Use before submission to check the currently assembled labels.

How to use this skill

Skill file

validate-and-apply-labels

Validates GitHub labels against the canonical set and maps branch type to labels.

When to use this skill

Before submit-pr, to apply the current branch-type mapping, validate label shape or membership against the available policy, and confirm exactly one changelog-decision label is present.

Input

{
  labels: string[],      // e.g. ["type:feature", "area:agents"]
  branchType: string,    // optional: for conditional labels
  templateFile: string,  // optional: PR template file
  config: object,        // optional
  mockGitHub: object,    // optional: for testing
}

Behaviour

Output

Branch-type mapping returns the applied labels and any mapping validation errors:

{
  valid: boolean,
  appliedLabels: string[],
  branchType: string,
  templateFile: string,
  validationErrors: string[],
  warnings: string[],
  deduplicatedCount: number,
  metadata: {
    typeLabels: string[],
    contextLabels: string[],
    totalLabels: number,
  },
}

Invalid branch-type mapping input omits templateFile, deduplication data, and metadata:

{
  valid: false,
  error: string,
  appliedLabels: [],
  branchType: unknown,
  validationErrors: [],
  warnings: [],
}

Direct label validation returns label-specific errors and may identify invalid or conflicting labels:

{
  valid: boolean,
  appliedLabels: string[],
  errors: string[] | undefined,
  deduplicatedCount: number,
  validationErrors: string[],
  warnings: string[],
  invalidLabels?: unknown[],
  conflicts?: Array<{ family: string, labels: string[] }>,
}

Usage

import { validateAndApplyLabels } from './scripts/validate-and-apply-labels.js';

const result = await validateAndApplyLabels({
  labels: ['meta:no-changelog'],
  branchType: 'feat',
  templateFile: 'pr_feature.md',
});
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.