Knowledge Graph - Graph Template Query Generator
/install graph-template-query-generator
Template Query Generator
Generate reusable graph query templates for common graph database operations.
This skill produces parameterized query templates that developers can quickly adapt to query graph databases without writing queries from scratch.
It supports template generation for common tasks such as:
- node lookup
- relationship traversal
- path discovery
- aggregations
- filtering
- graph exploration
Templates can be generated for graph query languages such as Cypher and SPARQL.
📋 Quick Start
When To Use This Skill
Use this skill when a user wants to:
- generate common graph queries
- create reusable query templates
- quickly scaffold Cypher or SPARQL queries
- explore graph data structures
- build starter queries for applications
- standardize query patterns
- document query patterns
Example Requests
- "Generate a query template for finding relationships."
- "Create a Cypher template to search nodes by property."
- "Generate a SPARQL query template for retrieving entities."
- "Create a reusable graph query."
- "Give me a template for path discovery."
- "Generate aggregation templates."
🎯 What This Skill Produces
The skill generates parameterized templates for:
- Node Queries - Finding nodes by label and properties
- Relationship Queries - Traversing relationships between nodes
- Path Queries - Discovering paths through the graph
- Aggregation Queries - Computing statistics and summaries
- Filtering Queries - Filtering nodes by conditions
- Graph Exploration - Discovering graph structure
- Multi-Hop Queries - Complex traversals across multiple hops
- Comparison Queries - Comparing entities and relationships
Templates typically include query parameters to allow easy reuse.
🔍 Template Categories
1. Node Lookup Templates (Basic)
Cypher template:
MATCH (n:$label {$property: $value})
RETURN n
LIMIT $limit
Example:
MATCH (p:Person {email: $email})
RETURN p
Parameters:
label: Node label (e.g., Person, Company)property: Property name (e.g., email, id)value: Property valuelimit: Result limit (default: 10)
2. Relationship Traversal Templates
Cypher template:
MATCH (a:$sourceLabel)-[:$relationshipType]->(b:$targetLabel)
RETURN a, b
LIMIT $limit
Example:
MATCH (p:Person)-[:WORKS_AT]->(c:Company)
RETURN p, c
Parameters:
sourceLabel: Starting node labelrelationshipType: Relationship typetargetLabel: Target node labellimit: Result limit
3. Multi-Hop Path Templates
Cypher template:
MATCH path = (start:$startLabel)-[*1..$depth]-(end:$endLabel)
RETURN path
LIMIT $limit
Example:
MATCH path = (p:Person)-[*1..3]-(target)
RETURN path
LIMIT 50
Parameters:
startLabel: Starting node labelendLabel: Ending node labeldepth: Maximum traversal depthlimit: Result limit
4. Aggregation Templates
Cypher template:
MATCH (source:$sourceLabel)-[:$relationshipType]->(target:$targetLabel)
RETURN target.$property, COUNT(DISTINCT source) as count
GROUP BY target.$property
ORDER BY count DESC
LIMIT $limit
Example:
MATCH (p:Person)-[:WORKS_AT]->(c:Company)
RETURN c.name, COUNT(DISTINCT p) as employee_count
GROUP BY c.name
ORDER BY employee_count DESC
LIMIT 10
5. Filtering Templates
Cypher template:
MATCH (n:$label)
WHERE n.$property $operator $value
RETURN n
LIMIT $limit
Example:
MATCH (p:Person)
WHERE p.age > 30
RETURN p
LIMIT 100
Parameters:
label: Node labelproperty: Property to filteroperator: Comparison operator (>, \x3C, =, !=)value: Filter valuelimit: Result limit
6. Property Filtering Templates
Cypher template:
MATCH (n:$label)
WHERE n.$property CONTAINS $value
RETURN n
LIMIT $limit
Example:
MATCH (p:Product)
WHERE p.description CONTAINS $search_term
RETURN p
LIMIT 20
7. Conditional Aggregation Templates
Cypher template:
MATCH (source:$sourceLabel)-[:$relationshipType]->(target:$targetLabel)
WHERE target.$filterProperty $operator $filterValue
RETURN target.$groupProperty, COUNT(source) as count
GROUP BY target.$groupProperty
ORDER BY count DESC
LIMIT $limit
8. Relationship Count Templates
Cypher template:
MATCH (n:$label)-[r:$relationshipType]->()
RETURN n, COUNT(r) as relationship_count
ORDER BY relationship_count DESC
LIMIT $limit
Example:
MATCH (p:Person)-[r:FOLLOWS]->()
RETURN p, COUNT(r) as follower_count
ORDER BY follower_count DESC
LIMIT 10
🔗 SPARQL Template Examples
SPARQL Node Lookup
PREFIX ex: \x3Chttp://example.org/>
SELECT ?entity
WHERE {
?entity a ex:$class ;
ex:$property $value .
}
LIMIT $limit
SPARQL Relationship Query
PREFIX ex: \x3Chttp://example.org/>
SELECT ?subject ?object
WHERE {
?subject ex:$predicate ?object .
}
LIMIT $limit
SPARQL Triple Pattern
PREFIX ex: \x3Chttp://example.org/>
SELECT ?resource
WHERE {
?resource a ex:$class .
?resource ex:$property ?value .
}
LIMIT $limit
💡 Template Generation Workflow
When generating query templates:
Step 1: Identify Query Goal
- Node lookup
- Relationship discovery
- Path exploration
- Aggregation
- Filtering
Step 2: Select Graph Pattern
- Choose appropriate pattern for goal
- Determine node labels/relationship types
- Identify parameterization points
Step 3: Insert Parameters
- Mark values as
$parameter - Choose meaningful parameter names
- Document parameter types
Step 4: Generate Target Syntax
- Cypher or SPARQL
- Validate syntax
- Include query explanation
Step 5: Create Usage Example
- Show concrete instantiation
- Document parameter values
- Provide integration guidance
📋 Output Formats
The skill returns:
1. Query Template
Parameterized Cypher or SPARQL query ready for reuse.
2. Parameter List
{
"label": "string - Node label",
"property": "string - Property name",
"value": "any - Property value",
"limit": "integer - Result limit (default: 10)"
}
3. Query Explanation
Plain English description of query purpose and behavior.
4. Usage Example
Concrete instantiation with sample parameter values.
5. Performance Notes
Index recommendations and optimization suggestions.
📈 Template Performance Guidelines
Node Lookup Templates
- Performance: O(1) with index on label + property
- Index Recommendation: Create index on queried property
- Typical Execution: \x3C 10 ms
- Best For: Single entity retrieval
Relationship Templates
- Performance: O(n) where n = source cardinality
- Index Recommendation: Index relationship type
- Typical Execution: 10-100 ms
- Best For: Specific relationship queries
Path Templates
- Performance: O(n^depth) exponential in depth
- Index Recommendation: Bound depth to ≤ 3
- Typical Execution: 100-1000 ms
- Best For: Discovery with bounded depth
Aggregation Templates
- Performance: O(n log n) with grouping
- Index Recommendation: Index group property
- Typical Execution: 50-500 ms
- Best For: Statistical summaries
✅ Best Practices
When designing query templates:
-
Use Clear Parameter Names
$emailinstead of$e$depthinstead of$d$company_nameinstead of$c_n
-
Include Result Limits
- Always add
LIMIT $limitclause - Default limit to 10 or 50
- Prevents memory issues
- Always add
-
Avoid Unbounded Traversal
- Use
[*1..3]instead of[*] - Bound path depth to 3-5 hops
- Document depth restrictions
- Use
-
Design for Reusability
- Make templates work across datasets
- Parameterize all variable values
- Use standard naming conventions
-
Include Documentation
- Parameter descriptions
- Example values
- Performance characteristics
-
Index Awareness
- Recommend indexes for filtered properties
- Consider composite indexes
- Document index creation
-
Error Handling
- Validate parameter types
- Handle null values
- Provide default behaviors
-
Template Versioning
- Track template versions
- Support template evolution
- Document changes
🔗 Integration with Other Skills
This skill integrates with:
- graph-query-debugging-tool - Debug generated templates
- graph-query-optimization-assistant - Optimize templates further
- nl-to-graph-query-translator - Translate natural language to templates
- graph-schema-validation - Validate templates against schema
- multi-hop-reasoning-query-builder - Build complex path templates
📚 Template Usage Scenarios
Scenario 1: Web Application
Goal: Find user by email
Generated: SELECT ?user WHERE { ?user foaf:email $email }
Usage: Execute in REST API endpoint
Scenario 2: Analytics Dashboard
Goal: Aggregate employee counts by company
Generated: Match relationships, group by company, count
Usage: Update dashboard monthly
Scenario 3: Mobile App
Goal: Get person's network (friends and followers)
Generated: Multi-hop path template with depth limit
Usage: Paginated results in app
Scenario 4: Data Export
Goal: Export all entities of type with properties
Generated: Complete node projection template
Usage: Scheduled export job
📖 Summary
This skill generates reusable graph query templates for common database operations.
It helps developers quickly scaffold Cypher or SPARQL queries, improving productivity and reducing query-writing effort through standardized, production-ready templates.
Status: Enterprise-Grade Template Generation
Comprehensive template library and generation system for professional knowledge graph development.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install graph-template-query-generator - 安装完成后,直接呼叫该 Skill 的名称或使用
/graph-template-query-generator触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Knowledge Graph - Graph Template Query Generator 是什么?
Generate reusable Cypher or SPARQL query templates for common graph database operations such as finding nodes, relationships, paths, and aggregations. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 39 次。
如何安装 Knowledge Graph - Graph Template Query Generator?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install graph-template-query-generator」即可一键安装,无需额外配置。
Knowledge Graph - Graph Template Query Generator 是免费的吗?
是的,Knowledge Graph - Graph Template Query Generator 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Knowledge Graph - Graph Template Query Generator 支持哪些平台?
Knowledge Graph - Graph Template Query Generator 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Knowledge Graph - Graph Template Query Generator?
由 Muhammad Asif(@fisa712)开发并维护,当前版本 v1.0.1。