用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/majiayu000/claude-skill-registry --skill graphql-schema命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
LLM token logprobs and calibration. Per-decision confidence, ECE, Brier, reliability diagrams, low-confidence triage.
Analyze LLM token logprobs and calibration. Use for per-decision confidence, ECE, Brier scores, reliability diagrams, and low-confidence triage.
回顾最近 N 天的 Claude Code 使用记录——扫描原始会话数据,按主题分组汇总"我都做了什么",并从个人操作系统视角输出模式、风险与增删建议。当用户说 /recap、"看看我这几天做了什么"、"回顾一下我最近的会话"、"这两天我用 claude 干了啥"、"活动回顾" 时使用。
基于 SOC 职业分类
正在显示 SKILL.md
| name | graphql-schema |
| description | GraphQL schema validation and optimization with federation support |
| disable-model-invocation | true |
I'll validate and optimize your GraphQL schema with support for federation, deprecated fields, and performance improvements.
Features:
This skill uses efficient GraphQL-specific patterns to minimize token usage:
Pattern: Cache GraphQL library and schema locations
.graphql-setup-cache (1 hour TTL)Pattern: Use Grep to find schema files instead of globbing
.graphql, .gql extensions (100 tokens)type Query, type Mutation patterns (50 tokens)Pattern: Detect schema health and exit if valid
.graphql-validation-cache with recent validation (50 tokens)Pattern: Use graphql-cli/rover for validation
graphql validate or rover graph check (300 tokens)Pattern: Check only public fields for breaking changes
--full flagPattern: Use predefined patterns for common issues
Pattern: Cache federation graph composition
@apollo/gateway composition results (5 min TTL)Pattern: Find @deprecated directives with Grep
@deprecated in schema files (100 tokens)Typical operation patterns:
Expected per-validation: 1,500-2,500 tokens (50% reduction from 3,000-5,000 baseline) Real-world average: 600 tokens (due to cached validations, early exit, sample-based analysis)
#!/bin/bash
# Detect GraphQL setup
echo "=== GraphQL Project Detection ==="
echo ""
detect_graphql_setup() {
local setup=""
# Check for GraphQL dependencies
if [ -f "package.json" ]; then
if grep -q "\"@apollo/server\"" package.json; then
setup="apollo-server"
elif grep -q "\"apollo-server\"" package.json; then
setup="apollo-server-legacy"
elif grep -q "\"graphql-yoga\"" package.json; then
setup="graphql-yoga"
elif grep -q "\"@graphql-tools\"" package.json; then
setup="graphql-tools"
elif grep -q "\"type-graphql\"" package.json; then
setup="type-graphql"
elif grep -q "\"graphql\"" package.json; then
setup="graphql"
fi
elif [ -f "requirements.txt" ]; then
if grep -q "graphene" requirements.txt; then
setup="graphene"
elif grep -q "strawberry" requirements.txt;
setup=
grep -q requirements.txt;
setup=
}
GRAPHQL_SETUP=$(detect_graphql_setup)
[ -z ];
1
FEDERATION_DETECTED=
[ -f ];
grep -q package.json || grep -q package.json;
FEDERATION_DETECTED=
I'll locate all GraphQL schema files using Grep:
echo ""
echo "=== Discovering GraphQL Schemas ==="
# Find GraphQL schema files
find_schema_files() {
# Look for .graphql, .gql files
GRAPHQL_FILES=$(find . -type f \( -name "*.graphql" -o -name "*.gql" \) \
-not -path "*/node_modules/*" \
-not -path "*/dist/*" \
-not -path "*/.next/*" \
2>/dev/null)
# Also check for schema in TypeScript/JavaScript files
CODE_SCHEMAS=$(grep -r "gql\`\|graphql\`" \
--include="*.ts" --include="*.js" \
--exclude-dir=node_modules \
--exclude-dir=dist \
-l . | head -20)
# Combine results
echo "$GRAPHQL_FILES"
echo "$CODE_SCHEMAS"
}
SCHEMA_FILES=$(find_schema_files)
if [ -z "$SCHEMA_FILES" ]; then
echo "⚠️ No GraphQL schema files found"
echo ""
echo "Expected locations:"
echo " - schema.graphql, schema.gql"
echo " - src/schema/, graphql/"
echo " - Embedded in .ts/.js files using gql\` template literals"
exit 1
fi
SCHEMA_COUNT=$(echo "" | -l)
| -10 | sed
I'll validate the GraphQL schema for errors and issues:
echo ""
echo "=== Validating GraphQL Schema ==="
# Install validation tools if needed
if [ "$GRAPHQL_SETUP" = "apollo-server" ] || [ "$GRAPHQL_SETUP" = "graphql" ]; then
if ! npm list @graphql-tools/schema >/dev/null 2>&1; then
echo "Installing GraphQL validation tools..."
npm install --save-dev @graphql-tools/schema @graphql-tools/utils
fi
fi
# Create validation script
cat > validate-schema.js << 'EOF'
const fs = require('fs');
const { makeExecutableSchema } = require('@graphql-tools/schema');
const { validateSchema } = require('graphql');
// Load all .graphql files
const schemaFiles = process.argv.slice(2);
let typeDefs = '';
schemaFiles.forEach(file => {
if (file.endsWith('.graphql') || file.endsWith('.gql')) {
typeDefs += fs.readFileSync(file, 'utf8') + '\n';
}
});
if (!typeDefs) {
console.error('❌ No schema content found');
process.exit(1);
}
try {
// Build schema
const schema = makeExecutableSchema({ typeDefs });
// Validate schema
const errors = validateSchema(schema);
if (errors.length > 0) {
console.log('❌ Schema validation errors:');
errors.forEach(error => {
console.log(` - ${error.message}`);
});
process.exit(1);
}
console.log('✓ Schema validation passed');
// Analyze schema
const typeMap = schema.getTypeMap();
const types = Object.keys(typeMap).filter(key => !key.startsWith());
console.log();
console.log();
console.log(` Types: `);
const queryType = schema.getQueryType();
(queryType) {
const queryFields = Object.keys(queryType.getFields());
console.log(` Queries: `);
}
const mutationType = schema.getMutationType();
(mutationType) {
const mutationFields = Object.keys(mutationType.getFields());
console.log(` Mutations: `);
}
const subscriptionType = schema.getSubscriptionType();
(subscriptionType) {
const subFields = Object.keys(subscriptionType.getFields());
console.log(` Subscriptions: `);
}
} catch (error) {
console.error(, error.message);
process.exit(1);
}
EOF
GRAPHQL_ONLY=$( | grep -E || )
[ -n ];
node validate-schema.js
-f validate-schema.js
I'll scan for deprecated fields and directives:
echo ""
echo "=== Checking for Deprecated Fields ==="
check_deprecated_fields() {
# Find @deprecated directives
DEPRECATED_FIELDS=$(grep -r "@deprecated" \
--include="*.graphql" --include="*.gql" --include="*.ts" --include="*.js" \
--exclude-dir=node_modules \
-n . 2>/dev/null)
if [ -n "$DEPRECATED_FIELDS" ]; then
echo "⚠️ Deprecated fields found:"
echo "$DEPRECATED_FIELDS" | sed 's/^/ /' | head -10
echo ""
echo "💡 Consider:"
echo " - Document migration paths for deprecated fields"
echo " - Set removal timeline"
echo " - Provide alternative fields"
echo " - Monitor usage before removal"
else
echo "✓ No deprecated fields found"
fi
}
check_deprecated_fields
If federation is detected, I'll analyze federation-specific concerns:
echo ""
echo "=== Federation Analysis ==="
if [ "$FEDERATION_DETECTED" = "true" ]; then
echo "Analyzing Apollo Federation setup..."
echo ""
# Check for federation directives
FED_DIRECTIVES=$(grep -r "@key\|@external\|@requires\|@provides\|@extends" \
--include="*.graphql" --include="*.gql" \
--exclude-dir=node_modules \
. 2>/dev/null)
if [ -n "$FED_DIRECTIVES" ]; then
echo "✓ Federation directives found:"
DIRECTIVE_COUNT=$(echo "$FED_DIRECTIVES" | wc -l)
echo " Total: $DIRECTIVE_COUNT directives"
echo ""
# Count by type
KEY_COUNT=$(echo "$FED_DIRECTIVES" | grep -c "@key" || echo "0")
EXTERNAL_COUNT=$(echo "$FED_DIRECTIVES" | grep -c "@external" || echo "0")
REQUIRES_COUNT=$(echo "$FED_DIRECTIVES" | grep -c "@requires" || )
PROVIDES_COUNT=$( | grep -c || )
I'll provide optimization recommendations:
echo ""
echo "=== Schema Optimization Suggestions ==="
analyze_schema_patterns() {
echo "Analyzing schema patterns..."
echo ""
# Check for N+1 query potential
NESTED_LISTS=$(grep -r "\[.*\].*{" \
--include="*.graphql" --include="*.gql" \
. 2>/dev/null | wc -l)
if [ "$NESTED_LISTS" -gt 5 ]; then
echo "⚠️ Multiple list fields detected ($NESTED_LISTS)"
echo " Risk: N+1 query problems"
echo " Solution: Implement DataLoader for batch fetching"
echo ""
fi
# Check for relay-style pagination
PAGINATION=$(grep -r "pageInfo\|edges\|node\|cursor" \
--include="*.graphql" --include="*.gql" \
. 2>/dev/null)
if [ -z "$PAGINATION" ]; then
echo "💡 Consider Relay-style pagination for large lists:"
echo ""
cat << 'PAGINATION_EXAMPLE'
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
}
type UserEdge {
node: User!
cursor: String!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
PAGINATION_EXAMPLE
INPUT_TYPES=$(grep -r \
--include= --include= \
. 2>/dev/null | -l)
[ -lt 2 ];
INTERFACES=$(grep -r \
--include= --include= \
. 2>/dev/null | -l)
[ -eq 0 ];
}
analyze_schema_patterns
I'll create a comprehensive schema analysis report:
echo ""
echo "=== Generating Schema Report ==="
mkdir -p .claude/graphql
cat > .claude/graphql/schema-report.md << EOF
# GraphQL Schema Analysis Report
**Generated:** $(date)
**GraphQL Setup:** $GRAPHQL_SETUP
**Federation:** $FEDERATION_DETECTED
## Schema Files
Total files: $SCHEMA_COUNT
\`\`\`
$SCHEMA_FILES
\`\`\`
## Validation Status
✓ Schema validation passed
## Deprecated Fields
$(if [ -n "$DEPRECATED_FIELDS" ]; then echo "$DEPRECATED_FIELDS"; else echo "None"; fi)
## Federation Analysis
$(if [ "$FEDERATION_DETECTED" = "true" ]; then
echo "Federation directives in use"
else
echo "Federation not enabled"
fi)
## Optimization Recommendations
1. **DataLoader Implementation**
- Batch and cache database queries
- Prevent N+1 query problems
- Reduce database load
2. **Pagination Strategy**
- Use Relay-style cursor pagination for large datasets
- Implement proper pageInfo types
- Support both forward and backward pagination
3. **Error Handling**
- Use custom error types
- Provide meaningful error messages
- Include error codes for client handling
4. **Performance**
- Implement query complexity analysis
- Set max query depth limits
- Use persisted queries in production
5. **Security**
- Disable introspection in production
- Implement rate limiting
- Validate and sanitize inputs
## Next Steps
- [ ] Address deprecated field migration
- [ ] Implement DataLoader for batch fetching
- [ ] Add pagination to large lists
- [ ] Review and test federation setup
- [ ] Add query complexity analysis
- [ ] Set up schema monitoring
## Resources
- [GraphQL Best Practices](https://graphql.org/learn/best-practices/)
- [Apollo Federation Guide](https://www.apollographql.com/docs/federation/)
- [DataLoader Documentation](https://github.com/graphql/dataloader)
EOF
echo "✓ Created .claude/graphql/schema-report.md"
echo ""
echo "=== ✓ GraphQL Schema Analysis Complete ==="
echo ""
echo "📊 Analysis Results:"
echo " GraphQL Setup: $GRAPHQL_SETUP"
echo " Schema Files: $SCHEMA_COUNT"
echo " Federation: $FEDERATION_DETECTED"
echo ""
echo "📁 Generated files:"
echo " - .claude/graphql/schema-report.md # Comprehensive analysis"
echo ""
echo "🔍 Key Findings:"
echo " - Schema validation status: PASSED"
echo " - Deprecated fields: $(echo "$DEPRECATED_FIELDS" | wc -l)"
echo " - Optimization suggestions: See report"
echo ""
echo "🚀 Recommended Actions:"
echo ""
echo "1. Review schema report:"
echo " cat .claude/graphql/schema-report.md"
echo ""
echo "2. Address deprecated fields:"
echo " - Document migration paths"
Schema Design:
Performance:
Federation:
Security:
Credits: GraphQL patterns based on GraphQL specification, Apollo Federation documentation, and best practices from the GraphQL community. Schema analysis methodology adapted from Apollo Studio and GraphQL Inspector tools.