skills/forge-graph-init/SKILL.md
[writes] Initialize Neo4j knowledge graph for codebase analysis. Use when setting up graph features for the first time, after Docker restarts, or when the graph is unavailable. Launches Docker container, imports plugin seed, builds project graph. Requires Docker. Trigger: /forge-graph-init, start knowledge graph, enable graph, set up Neo4j
npx skillsauth add quantumbitcz/dev-pipeline forge-graph-initInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are the graph initializer. Your job is to start the Neo4j container, import the plugin seed data, and build the project codebase graph. Be idempotent — detect what is already done and skip those steps.
See shared/skill-contract.md for the standard exit-code table.
Before any action, verify:
.claude/forge.local.md exists. If not: report "Pipeline not initialized. Run /forge-init first." and STOP.graph.enabled from .claude/forge.local.md. If false or absent: report "Graph integration is disabled in forge.local.md. Set graph.enabled: true to use this feature." and STOP.docker info. If fails: report "Docker is not available. Cannot start Neo4j container." and STOP.Before starting, resolve the Neo4j container name:
graph.neo4j_container_name from .claude/forge.local.mdforge-neo4jStore the resolved name and use it in ALL docker commands below (replacing forge-neo4j in the examples).
Work through these steps in order.
Check that .claude/forge.local.md exists in the project root.
/forge-init first." Abort.Read .claude/forge.local.md and check graph.enabled.
graph.enabled: false or the graph: section is absent: inform the user — "Graph integration is disabled in forge.local.md. Set graph.enabled: true to use this feature." Exit.Check Docker availability: docker info
.forge/state.json integrations: "neo4j": {"available": false}Copy the Docker Compose template to the pipeline working directory:
cp "${CLAUDE_PLUGIN_ROOT}/shared/graph/docker-compose.neo4j.yml" .forge/docker-compose.neo4j.yml
Substitute port variables from config (read graph.neo4j_port and graph.neo4j_bolt_port from forge.local.md, defaulting to 7474 and 7687 respectively). Edit the copied file to replace placeholder values with the resolved ports.
Check if the container is already running:
docker ps --filter "name=forge-neo4j" --format "{{.Names}}"
forge-neo4j appears in output: skip this step — container is already running.docker image inspect neo4j:5-community >/dev/null 2>&1
docker pull neo4j:5-community
docker compose -f .forge/docker-compose.neo4j.yml up -d
Important: The image tag neo4j:5-community uses a major-version floating tag, which always resolves to the latest 5.x release. This is intentional — Neo4j 5.x is backward-compatible within the major version. Do NOT pin to a specific patch version as it would require manual updates.
Poll the health check script until Neo4j is ready, up to 60 seconds:
"${CLAUDE_PLUGIN_ROOT}/shared/graph/neo4j-health.sh"
Run this in a loop (every 3 seconds) until it exits 0 or 60 seconds have elapsed.
docker logs forge-neo4j" Abort.Check for the seed marker node to determine if the seed has already been imported:
echo "MATCH (n:_SeedMarker {id: 'forge-seed-v2'}) RETURN count(n)" | \
docker exec -i forge-neo4j cypher-shell -u neo4j -p forge-local --format plain
cat "${CLAUDE_PLUGIN_ROOT}/shared/graph/seed.cypher" | \
docker exec -i forge-neo4j cypher-shell -u neo4j -p forge-local
Check .forge/graph/.last-build-sha — if it exists and matches the current git rev-parse HEAD, the graph is already up to date for this commit; skip rebuild and note this to the user.
After container startup, derive project_id:
PROJECT_ID=$(derive_project_id "$PROJECT_ROOT")
Pass to build-project-graph.sh:
./shared/graph/build-project-graph.sh --project-root "$PROJECT_ROOT" --project-id "$PROJECT_ID"
For monorepo with components, iterate each component:
for component in $(read_components "$PROJECT_ROOT"); do
./shared/graph/build-project-graph.sh --project-root "$PROJECT_ROOT" --project-id "$PROJECT_ID" --component "$component"
done
Otherwise, build the project graph:
"${CLAUDE_PLUGIN_ROOT}/shared/graph/build-project-graph.sh" --project-root . | \
docker exec -i forge-neo4j cypher-shell -u neo4j -p forge-local
After success, write the current commit SHA to .forge/graph/.last-build-sha.
Create .forge/graph/ directory if it does not exist.
Update .forge/state.json integrations block:
"neo4j": {
"available": true
}
If .forge/state.json does not exist or has no integrations key, create/add the key. Do not overwrite unrelated fields.
Query and display node counts:
echo "MATCH (n) RETURN labels(n)[0] AS label, count(*) AS count ORDER BY count DESC" | \
docker exec -i forge-neo4j cypher-shell -u neo4j -p forge-local --format plain
Present a summary:
Graph initialized successfully.
Container: forge-neo4j (running)
Seed: imported
Build SHA: <sha>
Node counts:
ProjectFile 142
ProjectClass 38
ProjectFunction 215
...
Run /forge-graph-query to explore the graph.
Run /forge-graph-status for health and coverage details.
Note any steps that were skipped (idempotency).
| Condition | Action |
|-----------|--------|
| forge.local.md missing | Report "Pipeline not initialized. Run /forge-init first." and STOP |
| graph.enabled is false | Report "Graph integration is disabled in forge.local.md. Set graph.enabled: true to use this feature." and STOP |
| Docker not available | Report "Docker is not available. Cannot start Neo4j container." Update state integrations and STOP |
| Docker image pull fails | Report "Failed to pull Neo4j image. Check internet connection and Docker Hub access." and STOP |
| Container start fails | Report error output. Suggest checking port conflicts (docker ps) and disk space |
| Neo4j health timeout (60s) | Report "Neo4j did not become healthy within 60 seconds. Check container logs: docker logs forge-neo4j." and STOP |
| Seed import fails | Report error. Container is running but seed is missing. Suggest retrying /forge-graph-init |
| Build script fails | Report error. Suggest checking that build-project-graph.sh is executable |
| State corruption | Graph init creates/updates state.json integrations block independently |
/forge-graph-status -- Check graph health and node counts after initialization/forge-graph-query -- Run Cypher queries against the initialized graph/forge-graph-rebuild -- Rebuild project graph from scratch (preserves seed)/forge-graph-debug -- Diagnose graph issues if initialization produced unexpected results/forge-init -- Full project setup which includes graph initialization as an optional stepdevelopment
[writes] Build, fix, deploy, review, or modify code in this project. Universal entry for the forge pipeline. Auto-bootstraps on first run; brainstorms before planning when given a feature description. Use when you want to take any productive action: implementing features, fixing bugs, reviewing branches, deploying, committing, running migrations.
tools
[writes] Manage forge state and configuration: recovery, abort, config edits, session handoff, automations, playbooks, output compression, knowledge graph maintenance. Use when you need to recover from broken pipeline state, edit settings, or manage long-lived state.
development
[writes] Create, list, show, resume, or search forge session handoffs. Use when context is getting heavy and you want to transfer a forge run or conversation into a fresh Claude Code session, or to resume from a prior handoff artefact. Subcommands - no args (write), list, show, resume, search.
development
[writes] Manage the Neo4j knowledge graph. Subcommands: init, rebuild (writes); status, query <cypher>, debug (read-only). Requires Docker. No default — an explicit subcommand is required. Use when setting up the graph for the first time, rebuilding after major refactors, checking graph health, or running ad-hoc Cypher diagnostics.