Structured Data
Capability Metadata
| Field | Value |
|---|---|
| ID | CAP-016 |
| Version | v1.8 |
| Domain | Skill Pipeline |
| Status | Documented |
| Related | CAP-004, CAP-017, CAP-018, CAP-019 |
| Source | src/pipeline/skill-pipeline.ts |
| Stages | Score→Resolve→ModelFilter→CacheOrder→Budget→Load |
Configuration Reference
Pipeline configuration in integration.json
{
"pipeline": {
"stages": {
"score": { "enabled": true },
"resolve": { "enabled": true },
"model_filter": { "enabled": true },
"cache_order": { "enabled": true },
"budget": { "enabled": true },
"load": { "enabled": true }
},
"custom_stages": []
}
}
Disable a stage: set enabled: false for that stage key.
Inject custom stage: add entry to custom_stages array with name, module, and after (insertion point).
Technical Specifications
Class: SkillPipeline
// Core pipeline interface
interface PipelineStage {
name: string;
process(
input: PipelineData,
context: PipelineContext
): Promise<PipelineData>;
}
// Pipeline data flowing between stages
interface PipelineData {
skills: SkillCandidate[];
metadata: Record<string, unknown>;
diagnostics: StageDiagnostic[];
}
// Pipeline result returned to caller
interface PipelineResult {
loaded: Skill[];
deferred: Skill[];
rejected: Skill[];
budget_used: number;
cache_hits: number;
stage_timings: Record<string, number>;
}
Overview
The Skill Pipeline replaces the original monolithic skill loader with a six-stage composable architecture. Before v1.8, GSD Skill Creator loaded skills by iterating a list and stopping when a count or token ceiling was reached — a simple approach that worked at small scale but became a bottleneck as skill libraries grew. By v1.8, projects were accumulating dozens of skills, and the blunt "load the first N" strategy ignored relevance, model compatibility, and cache efficiency entirely.
The pipeline solves this by decomposing skill loading into discrete, ordered stages: Score, Resolve, ModelFilter, CacheOrder, Budget, and Load. Each stage receives the output of the previous one and applies a single, focused transformation. This separation of concerns makes the system transparent — you can inspect what each stage did, disable stages for debugging, or insert custom stages to implement project-specific behavior.
CAP-016 is the architectural foundation for all subsequent skill pipeline capabilities. CAP-017 (Token Budgets), CAP-018 (Capability Planning), and CAP-019 (Cache Optimization) are all implemented as pipeline stage configurations or extensions — they exist because the pipeline exists.
History
v1.8 — the "Capability-Aware Planning + Token Efficiency" release — introduced the pipeline as the central architectural change. The basic auto-loader from CAP-004 had served well through v1.7, but the team recognized that adding more features to a monolithic loader was unsustainable. Instead of extending the loader, they replaced its internals with the composable pipeline stage model.
The decision to use a linear pipeline (rather than a graph or event bus) was deliberate: pipelines are easy to reason about, easy to debug, and easy to extend at defined insertion points. The six-stage sequence was stable from the first release — no stages were added or removed in subsequent versions, though individual stages gained significant internal complexity.
In v1.19, the Budget Inventory Model (CAP-073) extended the Budget stage with a LoadingProjection that separated installed total from loadable total — improving budget accuracy substantially. The pipeline architecture made this enhancement possible without touching the other five stages.
Key Concepts
Think of the Skill Pipeline like the security line at an airport. You don't just walk straight onto the plane — you go through a series of checkpoints, each one doing a specific job before you move to the next.
First, an agent scans your ID (Score — "is this skill relevant to what we're doing?"). Then your bags go through X-ray (Resolve — "if two skills conflict, which one wins?"). Then you walk through the metal detector (ModelFilter — "does this skill work with the current AI model?"). Then you find your boarding gate (CacheOrder — "put frequently-used skills first so the AI remembers them faster"). Then the gate agent checks your bag fits in the overhead bin (Budget — "does this skill fit in the remaining context window?"). Finally, you board (Load — "add this skill to the AI's working context").
Each checkpoint only sees the passengers (skills) who made it through the previous one. And if a checkpoint is broken or unnecessary, you can bypass it — without affecting any of the others. That's what makes the pipeline composable.
Usage Examples
Example 1: Run the pipeline with default configuration
// The pipeline runs automatically on each GSD phase start.
// To run manually for debugging:
import { SkillPipeline } from 'src/pipeline/skill-pipeline';
const pipeline = new SkillPipeline();
const result = await pipeline.run({
context: currentPhaseContext,
model: 'claude-opus-4-6'
});
console.log(`Loaded: ${result.loaded.length} skills`);
console.log(`Budget used: ${result.budget_used} tokens`);
console.log(`Cache hits: ${result.cache_hits}`);
Example 2: Disable the CacheOrder stage for testing
// integration.json — temporarily disable cache ordering
{
"pipeline": {
"stages": {
"cache_order": { "enabled": false }
}
}
}
// Skills will still load correctly; they just won't be
// reordered for prompt cache optimization.
Example 3: Debug stage failures
// Each stage emits diagnostics on the PipelineData object
const result = await pipeline.run({ context, model });
result.loaded.forEach(skill => {
const diag = result.diagnostics[skill.id];
console.log(`${skill.id}: passed ${diag.stages_passed.join(' → ')}`);
});
result.rejected.forEach(skill => {
const diag = result.diagnostics[skill.id];
console.log(`${skill.id}: rejected at ${diag.rejected_at} — ${diag.reason}`);
});
Detailed Reference: The 6 Stages
Stage 1: Score
Computes a relevance score for each skill candidate against the current execution context (phase description, active files, recent commands). Skills below the relevance threshold are marked for early rejection — they don't proceed to later stages. Output: each skill has a relevance_score (0.0–1.0) attached.
Stage 2: Resolve
Handles conflicts when the same skill capability is provided by both a project-level skill and a user-level skill. Project-level always wins. If two project-level skills define overlapping triggers, the one with the higher version wins. Output: deduplicated skill list with conflicts resolved.
Stage 3: ModelFilter
Filters skills by model compatibility. Each skill's YAML frontmatter can declare model_min or model_requires constraints. Skills that require capabilities not available in the current model are rejected here. Output: skills guaranteed to be compatible with the active model.
Stage 4: CacheOrder
Reorders the skill list to maximize prompt cache hit probability. Skills marked cacheTier: hot are moved to stable positions that the Claude API's prompt cache recognizes across sessions. Skills marked cacheTier: cold are placed at the end (least likely to benefit from caching). Output: same skills, reordered for cache efficiency.
Stage 5: Budget
Enforces the token budget ceiling. Skills are accepted in priority order (critical → standard → optional) until the budget is exhausted. Remaining skills are placed in the deferred list — they are noted in the PipelineResult but not loaded. Output: final load list within budget.
Stage 6: Load
Injects the approved skill content into the agent context. This is the only stage that has side effects — all previous stages are pure transformations on the skill list. After loading, the PipelineResult is returned to the caller with full diagnostics.
Data Flow Between Stages
SkillCandidates[]
→ [Score] → candidates with relevance_score attached
→ [Resolve] → deduplicated candidates
→ [ModelFilter] → model-compatible candidates
→ [CacheOrder] → reordered candidates
→ [Budget] → candidates split into load/defer
→ [Load] → loaded skills injected into context
→ PipelineResult
Developer Reference: Writing Custom Pipeline Stages
PipelineStage Interface
interface PipelineStage {
name: string; // Unique identifier
process(
input: PipelineData, // Skills from previous stage
context: PipelineContext // Phase, model, config
): Promise<PipelineData>; // Modified skills for next stage
}
Input/Output Contracts
A stage receives PipelineData containing the current skills array plus accumulated diagnostics. It must return a new PipelineData object (do not mutate the input). Add diagnostic entries to explain why skills were kept, modified, or rejected.
Registering a Custom Stage
// integration.json
{
"pipeline": {
"custom_stages": [
{
"name": "my-domain-filter",
"module": ".claude/stages/domain-filter.js",
"after": "resolve" // Insert after the Resolve stage
}
]
}
}
Error Handling in Stages
If a stage throws, the pipeline catches the error and logs it as a diagnostic. The failed stage's input is passed to the next stage unchanged — the pipeline never halts due to a stage error. This ensures skill loading degrades gracefully rather than failing completely.
Stage Ordering Constraints
Custom stages may be inserted after any built-in stage name: score, resolve, model_filter, cache_order, budget. Insertion before the Score stage or after the Load stage is not supported.

