Skip to content

Commit 16b7fbf

Browse files
genezhangclaude
andcommitted
feat(skills): add publishable agent skills for NL→Cypher via cg CLI
Two framework-agnostic agent skills backed by the cg CLI: - skills/cypher.md — /cypher <NL query>: NL→Cypher→SQL→execute - skills/graph-schema.md — /graph-schema: show schema + validate skills/README.md covers installation for Claude Code, LangChain, AutoGen, CrewAI, and OpenAI function calling. Also: .gitignore negation for skills/, README and wiki updates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 863a782 commit 16b7fbf

6 files changed

Lines changed: 240 additions & 3 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ docs1/
127127
# Agent documentation for AI-assisted development
128128
!**/AGENTS.md
129129

130+
# Agent skills (publishable, for end-users)
131+
!skills/
132+
!skills/**
133+
130134
# Benchmark results
131135
!benchmarks/ldbc_snb/BENCHMARK_RESULTS.md
132136

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,26 @@ cd demos/neo4j-browser && bash setup.sh
176176
Then open http://localhost:7474 and connect to `bolt://localhost:7687`.
177177
See [demos/neo4j-browser/README.md](https://github.com/genezhang/clickgraph/blob/main/demos/neo4j-browser/README.md) for details.
178178

179-
### AI Assistant Integration (MCP)
179+
### AI Assistant Integration
180180

181-
ClickGraph implements `apoc.meta.schema()` and Neo4j-compatible schema procedures, enabling AI assistants (Claude, etc.) to discover your graph structure via MCP servers like [`@anthropic-ai/mcp-server-neo4j`](https://www.npmjs.com/package/@anthropic-ai/mcp-server-neo4j) and [`@neo4j/mcp-neo4j`](https://www.npmjs.com/package/@neo4j/mcp-neo4j).
181+
**Agent skills** — drop-in skills for Claude Code and other agentic frameworks, backed by the `cg` CLI (no MCP server needed):
182+
183+
```bash
184+
# Install for Claude Code
185+
mkdir -p .claude/commands
186+
curl -L https://raw.githubusercontent.com/genezhang/clickgraph/main/skills/cypher.md \
187+
-o .claude/commands/cypher.md
188+
curl -L https://raw.githubusercontent.com/genezhang/clickgraph/main/skills/graph-schema.md \
189+
-o .claude/commands/graph-schema.md
190+
191+
# Then in Claude Code:
192+
# /cypher find users with more than 10 followers
193+
# /graph-schema
194+
```
195+
196+
See **[skills/README.md](skills/README.md)** for installation across Claude Code, LangChain, AutoGen, CrewAI, and OpenAI function calling.
197+
198+
**MCP server** — for frameworks requiring the MCP protocol, ClickGraph implements `apoc.meta.schema()` and Neo4j-compatible schema procedures, compatible with [`@anthropic-ai/mcp-server-neo4j`](https://www.npmjs.com/package/@anthropic-ai/mcp-server-neo4j) and [`@neo4j/mcp-neo4j`](https://www.npmjs.com/package/@neo4j/mcp-neo4j).
182199

183200
See the **[MCP Setup Guide](https://github.com/genezhang/clickgraph/blob/main/docs/wiki/AI-Assistant-Integration-MCP.md)** for configuration details.
184201

docs/wiki/Home.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ curl -X POST http://localhost:8080/query \
7171
- **[Quick Start Guide](Quick-Start-Guide.md)** - 5-minute Docker setup (includes pre-built binary option)
7272
- **[Embedded Mode](Embedded-Mode.md)** - In-process graph queries over Parquet/Iceberg/Delta (no ClickHouse needed)
7373
- **[Language Bindings](Language-Bindings.md)** - Rust, Python, and Go library APIs
74+
- **[Agent Skills](Agent-Skills.md)** - `/cypher` and `/graph-schema` skills for Claude Code and any agent framework (backed by `cg` CLI, no MCP needed)
7475
- **[AI Assistant Integration (MCP)](AI-Assistant-Integration-MCP.md)** - Use ClickGraph with Claude via MCP; `cg` CLI for agent/script NL→Cypher
7576
- **[Schema Discovery](Schema-Discovery.md)** - LLM-powered schema generation (server or `cg schema discover`)
7677
- **[Your First Graph](Your-First-Graph.md)** - Build a simple social network graph
@@ -100,7 +101,8 @@ curl -X POST http://localhost:8080/query \
100101
- **[Performance Tuning](Performance-Query-Optimization.md)** - Query and schema optimization
101102

102103
### Integrations
103-
- **[AI Assistant Integration (MCP)](AI-Assistant-Integration-MCP.md)** - 🤖 Use ClickGraph with Claude and other AI assistants via Model Context Protocol
104+
- **[Agent Skills](Agent-Skills.md)** - `/cypher` and `/graph-schema` skills for Claude Code, LangChain, AutoGen, CrewAI, and OpenAI function calling
105+
- **[AI Assistant Integration (MCP)](AI-Assistant-Integration-MCP.md)** - Use ClickGraph with Claude and other AI assistants via Model Context Protocol
104106
- **[Neo4j Tools Integration](Neo4j-Tools-Integration.md)** - Connect Neo4j Browser, Neodash, and cypher-shell
105107
- **[Graph-Notebook Compatibility](Graph-Notebook-Compatibility.md)** - 📊 Jupyter notebook visualization with AWS graph-notebook
106108

skills/README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# ClickGraph Agent Skills
2+
3+
Agent skills for querying ClickGraph databases using natural language. Built on the `cg` CLI — no MCP server or running ClickGraph server required.
4+
5+
## Skills
6+
7+
| Skill | File | What it does |
8+
|-------|------|--------------|
9+
| `/cypher` | `cypher.md` | Translate natural language → Cypher → SQL → execute |
10+
| `/graph-schema` | `graph-schema.md` | Show graph schema (nodes, relationships, properties) |
11+
12+
## Prerequisites
13+
14+
1. **`cg` binary** — download from [GitHub Releases](https://github.com/genezhang/clickgraph/releases/latest) or build:
15+
```bash
16+
cargo build --release -p clickgraph-tool
17+
# binary at: target/release/cg
18+
```
19+
20+
2. **Schema file** — your graph schema YAML. Set once and forget:
21+
```bash
22+
export CG_SCHEMA="/path/to/schema.yaml"
23+
# or add to ~/.config/cg/config.toml:
24+
# [schema]
25+
# path = "/path/to/schema.yaml"
26+
```
27+
28+
3. **LLM API key** (for `/cypher` NL translation):
29+
```bash
30+
export ANTHROPIC_API_KEY="sk-ant-..."
31+
# or for OpenAI-compatible:
32+
# export CG_LLM_PROVIDER=openai
33+
# export OPENAI_API_KEY="sk-..."
34+
```
35+
36+
4. **ClickHouse URL** (optional — for query execution):
37+
```bash
38+
export CG_CLICKHOUSE_URL="http://localhost:8123"
39+
export CG_CLICKHOUSE_USER="default"
40+
export CG_CLICKHOUSE_PASSWORD=""
41+
```
42+
43+
## Installation by Framework
44+
45+
### Claude Code
46+
47+
Copy skill files into your project's `.claude/commands/` directory:
48+
49+
```bash
50+
mkdir -p .claude/commands
51+
curl -L https://raw.githubusercontent.com/genezhang/clickgraph/main/skills/cypher.md \
52+
-o .claude/commands/cypher.md
53+
curl -L https://raw.githubusercontent.com/genezhang/clickgraph/main/skills/graph-schema.md \
54+
-o .claude/commands/graph-schema.md
55+
```
56+
57+
Then use directly in Claude Code:
58+
```
59+
/cypher find users with more than 10 followers
60+
/graph-schema
61+
```
62+
63+
### Claude Desktop / any MCP client
64+
65+
Use the skills as reference prompts, or pair with the ClickGraph MCP server (see [AI-Assistant-Integration-MCP.md](../docs/wiki/AI-Assistant-Integration-MCP.md)).
66+
67+
### LangChain / AutoGen / CrewAI / custom agents
68+
69+
Use the skill file content as a system prompt or tool description. The `cg` CLI is the execution backend — call it as a subprocess:
70+
71+
```python
72+
import subprocess
73+
74+
def nl_to_cypher(query: str, schema: str, ch_url: str = None) -> dict:
75+
cmd = ["cg", "--schema", schema, "nl", query]
76+
if ch_url:
77+
cmd = ["cg", "--schema", schema, "--clickhouse", ch_url,
78+
"query", query] # use cg nl first, then query
79+
result = subprocess.run(cmd, capture_output=True, text=True)
80+
return {"output": result.stdout, "error": result.stderr}
81+
```
82+
83+
### OpenAI function calling
84+
85+
```json
86+
{
87+
"name": "clickgraph_query",
88+
"description": "Translate natural language to Cypher and execute against a ClickGraph database",
89+
"parameters": {
90+
"type": "object",
91+
"properties": {
92+
"query": {
93+
"type": "string",
94+
"description": "Natural language description of the graph query"
95+
}
96+
},
97+
"required": ["query"]
98+
}
99+
}
100+
```
101+
102+
Implement the function by calling `cg nl "$query"` (and optionally `cg query`).
103+
104+
## Configuration Reference
105+
106+
All configuration can be set via environment variables, CLI flags, or `~/.config/cg/config.toml`.
107+
108+
```toml
109+
# ~/.config/cg/config.toml
110+
[schema]
111+
path = "/path/to/schema.yaml"
112+
113+
[clickhouse]
114+
url = "http://localhost:8123"
115+
user = "default"
116+
password = ""
117+
118+
[llm]
119+
provider = "anthropic" # or "openai"
120+
model = "claude-sonnet-4-6"
121+
# api_key = "sk-..." # or set ANTHROPIC_API_KEY
122+
# base_url = "..." # for OpenRouter, Groq, Ollama, etc.
123+
```
124+
125+
See [clickgraph-tool/AGENTS.md](../clickgraph-tool/AGENTS.md) for the full `cg` CLI reference.

skills/cypher.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
description: Translate natural language to Cypher and query a ClickGraph database
3+
---
4+
5+
The user wants to query a graph database. Their request: $ARGUMENTS
6+
7+
Use the `cg` CLI tool to translate this to Cypher and optionally execute it.
8+
9+
## Step 1 — Locate the schema
10+
11+
Find the schema file in this priority order:
12+
1. `$CG_SCHEMA` environment variable
13+
2. `schema.yaml` or `schemas/*.yaml` in the current working directory
14+
3. `schema.path` in `~/.config/cg/config.toml`
15+
16+
If none found, ask the user to supply the path or set `CG_SCHEMA`.
17+
18+
## Step 2 — Generate Cypher
19+
20+
```bash
21+
cg --schema <path> nl "$ARGUMENTS"
22+
```
23+
24+
Display the generated Cypher in a code block. If the command fails, show the error and suggest checking the schema path and LLM API key (`ANTHROPIC_API_KEY` or `CG_LLM_API_KEY`).
25+
26+
## Step 3 — Show SQL translation
27+
28+
```bash
29+
cg --schema <path> sql "<generated cypher>"
30+
```
31+
32+
Show the SQL — this is useful for understanding what ClickHouse will execute and for debugging.
33+
34+
## Step 4 — Execute
35+
36+
If `CG_CLICKHOUSE_URL` is set (or `clickhouse.url` is in `~/.config/cg/config.toml`), execute:
37+
38+
```bash
39+
cg --schema <path> --clickhouse "$CG_CLICKHOUSE_URL" query "<generated cypher>"
40+
```
41+
42+
If ClickHouse is not configured, present the Cypher and SQL and suggest how to run it:
43+
- `cg query --clickhouse http://localhost:8123 "<cypher>"`
44+
- Via ClickGraph server: `curl -X POST http://localhost:8080/query -d '{"query": "<cypher>"}'`
45+
46+
## Notes
47+
48+
- `cg nl` requires an LLM API key: `ANTHROPIC_API_KEY` (default) or `OPENAI_API_KEY` with `CG_LLM_PROVIDER=openai`
49+
- Property names in Cypher follow the schema mappings, not raw ClickHouse column names
50+
- Use `cg schema show --schema <path>` to inspect available node labels and relationship types

skills/graph-schema.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
description: Show the ClickGraph graph schema — node labels, relationship types, and properties
3+
---
4+
5+
Show the graph schema for the ClickGraph database connected to this project.
6+
7+
## Step 1 — Locate the schema
8+
9+
Find the schema file in this priority order:
10+
1. `$CG_SCHEMA` environment variable
11+
2. `schema.yaml` or `schemas/*.yaml` in the current working directory
12+
3. `schema.path` in `~/.config/cg/config.toml`
13+
14+
If $ARGUMENTS is non-empty, treat it as the schema file path.
15+
16+
## Step 2 — Display the schema
17+
18+
```bash
19+
cg --schema <path> schema show
20+
```
21+
22+
This prints a compact Cypher-native view:
23+
- Node labels with their properties and types
24+
- Relationship types with directionality and endpoints
25+
- Which relationships are undirected
26+
27+
Summarise the schema for the user in plain language: what entities exist, how they are connected, and which properties are available for querying.
28+
29+
## Step 3 — Validate (always run this)
30+
31+
```bash
32+
cg --schema <path> schema validate
33+
```
34+
35+
Report any validation issues. A valid schema is required before running queries.
36+
37+
## Step 4 — Suggest queries (optional)
38+
39+
Based on the schema, offer 2–3 example Cypher queries the user could run, matched to their apparent use case. Use the `/cypher` skill (or `cg nl`) to execute them.

0 commit comments

Comments
 (0)