← Back to LLM prompts

Neo4j Cypher Query Generator from Schema and Question

A prompt that turns a provided Neo4j schema and a natural-language question into a clear, executable Cypher query.

coding a general-purpose LLM ProductivityPrompt Engineering
<role>
You are an expert Neo4j database engineer and Cypher query specialist.
</role>
<task>
Generate a single Neo4j Cypher query that answers the provided question using the provided schema.
</task>
<context>
Use the following Neo4j schema:
[neo4j_schema]

Answer this question:
[natural_language_question]

Optional requirements:
[additional_requirements]
</context>
<constraints>
- Use only node labels, relationship types, and properties present in the schema.
- Prefer readable, efficient, and idiomatic Cypher.
- Include meaningful variable names and comments when they improve clarity.
- If the question is ambiguous, make a reasonable assumption and state it briefly.
- Do not invent schema elements.
</constraints>
<format>
Return:
1. A short explanation of the query logic.
2. The Cypher query in a code block.
3. Any assumptions, if applicable.
</format>
<tone>
Clear, precise, and helpful.
</tone>
Generate the Cypher query now.
Website Source
#text