/major-ai-skills:graphql-introspection-trimmerfrom major-ai-skills
Extract operation-relevant GraphQL types from an introspection schema before building or debugging a query.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
When integrating with or debugging a GraphQL API, agents often run full schema introspection queries (__schema { types { name fields { name type } } }) or ingest full 10,000-line schema.graphql SDL files.
Full schema introspection results in massive Context Overflow: a production enterprise GraphQL schema (Shopify, GitHub, Stripe) is 500KB to 3MB of raw JSON (consuming 80,000+ tokens), even if the agent only needs to query 2 fields on the User object.
The GraphQL Schema Trimming Protocol parses the schema AST and extracts strictly the targeted operation and its transitively referenced types, discarding unreferenced queries, mutations, and deprecated fields.
┌─────────────────────────────────────────────────────────────┐
│ GraphQL Schema Context Impact │
│ │
│ Full Introspection JSON Dump (65,000 Tokens): │
│ • 420 Object Types (Billing, Inventory, Webhooks, Admin) │
│ • 180 Mutations & Subscriptions │
│ • 1,200 Field descriptions and deprecation reasons │
│ ↳ 65,000 tokens billed, blows context limit │
│ │
│ Targeted Subgraph SDL (240 Tokens - 99.6% Reduction!): │
│ type Query { getUser(id: ID!): User } │
│ type User { id: ID!, email: String!, role: Role! } │
│ enum Role { ADMIN, MEMBER, VIEWER } │
│ ↳ 240 clean tokens, exact type contracts preserved │
└─────────────────────────────────────────────────────────────┘
┌───────────────────────────────────────────────────────────────────────────┐
│ 1. IDENTIFY ROOT OPERATION: Target query (e.g. `Query.searchProducts`) │
│ 2. RECURSIVE TYPE RESOLUTION: Follow field return types & input arguments │
│ 3. STRIP METADATA: Drop description strings, `@deprecated`, & uncalled SDL│
└───────────────────────────────────────────────────────────────────────────┘
graphql-core)from graphql import parse, print_ast, TypeDefinitionNode, FieldDefinitionNode
from typing import Set
def prune_graphql_schema(sdl_source: str, target_queries: list) -> str:
"""Extracts only the types and fields required for specific queries."""
ast = parse(sdl_source)
needed_types: Set[str] = set(target_queries)
# 1. First pass: find return types of target queries
for defn in ast.definitions:
if getattr(defn, "name", None) and defn.name.value in ["Query", "Mutation"]:
for field in defn.fields:
if field.name.value in target_queries:
# Extract return type name
curr = field.type
while hasattr(curr, "type"):
curr = curr.type
needed_types.add(curr.name.value)
# 2. Second pass: filter definitions
pruned_definitions = [
defn for defn in ast.definitions
if getattr(defn, "name", None) and defn.name.value in needed_types
]
ast.definitions = pruned_definitions
return print_ast(ast)
graphql)import { buildSchema, print, parse } from "graphql";
export function getMinimalOperationSDL(fullSDL: string, rootTypeName: string): string {
const schema = buildSchema(fullSDL);
const targetType = schema.getType(rootTypeName);
if (!targetType) throw new Error(`Type ${rootTypeName} not found in schema.`);
// Return clean SDL representation for target type only
return `type ${targetType.name} {\n${Object.values(targetType.toConfig().fields || {})
.map((f: any) => ` ${f.name}: ${f.type.toString()}`)
.join("\n")}\n}`;
}
Querying a single user endpoint against a large e-commerce GraphQL schema:
| Schema Ingestion Strategy | Input Tokens | API Turn Cost | Latency |
|---|---|---|---|
| Full Introspection JSON | 72,000 tokens | $0.216 | 6.8 seconds |
Full Schema SDL (.graphql) | 28,500 tokens | $0.085 | 3.2 seconds |
| Pruned Targeted Subgraph SDL | 310 tokens | $0.0009 | 0.2 seconds (99.5% Savings!) |
MANDATORY: Never inject full GraphQL Introspection JSON dumps into conversation context. Use client-side AST tooling to prune the schema to the specific queries, mutations, and types required for the active prompt.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.Other plugins' skills for the same job