生成可重用的 Cypher 或 SPARQL 查询模板,用于常见的图数据库操作,如查找节点、关系、路径和聚合。
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:
Templates can be generated for graph query languages such as Cypher and SPARQL.
Use this skill when a user wants to:
The skill generates parameterized templates for:
Templates typically include query parameters to allow easy reuse.
Cypher template:
cypher
MATCH (n:$label {$property: $value})
RETURN n
LIMIT $limit
Example:
cypher
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)Cypher template:
cypher
MATCH (a:$sourceLabel)-[:$relationshipType]->(b:$targetLabel)
RETURN a, b
LIMIT $limit
Example:
cypher
MATCH (p:Person)-[:WORKS_AT]->(c:Company)
RETURN p, c
Parameters:
sourceLabel: Starting node labelrelationshipType: Relationship typetargetLabel: Target node labellimit: Result limitCypher template:
cypher
MATCH path = (start:$startLabel)-[*1..$depth]-(end:$endLabel)
RETURN path
LIMIT $limit
Example:
cypher
MATCH path = (p:Person)-[*1..3]-(target)
RETURN path
LIMIT 50
Parameters:
startLabel: Starting node labelendLabel: Ending node labeldepth: Maximum traversal depthlimit: Result limitCypher template:
cypher
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:
cypher
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
Cypher template:
cypher
MATCH (n:$label)
WHERE n.$property $operator $value
RETURN n
LIMIT $limit
Example:
cypher
MATCH (p:Person)
WHERE p.age > 30
RETURN p
LIMIT 100
Parameters:
label: Node labelproperty: Property to filteroperator: Comparison operator (>, <, =, !=)value: Filter valuelimit: Result limitCypher template:
cypher
MATCH (n:$label)
WHERE n.$property CONTAINS $value
RETURN n
LIMIT $limit
Example:
cypher
MATCH (p:Product)
WHERE p.description CONTAINS $search_term
RETURN p
LIMIT 20
Cypher template:
cypher
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
Cypher template:
cypher
MATCH (n:$label)-[r:$relationshipType]->()
RETURN n, COUNT(r) as relationship_count
ORDER BY relationship_count DESC
LIMIT $limit
Example:
cypher
MATCH (p:Person)-[r:FOLLOWS]->()
RETURN p, COUNT(r) as follower_count
ORDER BY follower_count DESC
LIMIT 10
sparql
PREFIX ex: <http://example.org/>
SELECT ?entity
WHERE {
?entity a ex:$class ;
ex:$property $value .
}
LIMIT $limit
sparql
PREFIX ex: <http://example.org/>
SELECT ?subject ?object
WHERE {
?subject ex:$predicate ?object .
}
LIMIT $limit
sparql
PREFIX ex: <http://example.org/>
SELECT ?resource
WHERE {
?resource a ex:$class .
?resource ex:$property ?value .
}
LIMIT $limit
When generating query templates:
$parameterThe skill returns:
Parameterized Cypher or SPARQL query ready for reuse.
json
{
"label": "string - Node label",
"property": "string - Property name",
"value": "any - Property value",
"limit": "integer - Result limit (default: 10)"
}
Plain English description of query purpose and behavior.
Concrete instantiation with sample parameter values.
Index recommendations and optimization suggestions.
When designing query templates:
$email instead of $e$depth instead of $d$company_name instead of $c_nLIMIT $limit clause[*1..3] instead of [*]This skill integrates with:
text
Goal: Find user by email
Generated: SELECT ?user WHERE { ?user foaf:email $email }
Usage: Execute in REST API endpoint
text
Goal: Aggregate employee counts by company
Generated: Match relationships, group by company, count
Usage: Update dashboard monthly
text
Goal: Get person's network (friends and followers)
Generated: Multi-hop path template with depth limit
Usage: Paginated results in app
text
Goal: Export all entities of type with properties
Generated: Complete node projection template
Usage: Scheduled export job
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.