nacl-migrate-ba
Skill27 starsChanged 5 months agoMITView on GitHub
Migrate an OLD-methodology BA layer from Markdown to Neo4j. Parses docs/00-context, docs/01-business-processes, docs/02-business-entities, docs/03-business-roles, docs/04-business-rules, docs/99-meta/glossary via deterministic Python scripts (no LLM parsing), then writes BA nodes and relationships to the graph via mcp__neo4j__write-cypher. Use when: migrate BA from markdown, import old BA into graph, nacl-migrate-ba. Fails loudly on unknown formats — add a new adapter rather than guessing.
- Installs packages
In this repository60 other files it gives its agents.
- docs/agents.mdAGENTS.md
- analyst-tool/CLAUDE.mdCLAUDE.md
- nacl-ba-analyzeSkill
- nacl-ba-contextSkill
- nacl-ba-entitiesSkill
- nacl-ba-from-boardSkill
- nacl-ba-fullSkill
- nacl-ba-glossarySkill
- nacl-ba-handoffSkill
- nacl-ba-import-docSkill
- nacl-ba-processSkill
- nacl-ba-rolesSkill
- nacl-ba-rulesSkill
- nacl-ba-syncSkill
- nacl-ba-validateSkill
- nacl-ba-workflowSkill
- nacl-coreSkill
- nacl-goalSkill
- nacl-initSkill
- nacl-migrate-saSkill
- nacl-migrateSkill
- nacl-postmortemSkill
- nacl-publishSkill
- nacl-renderSkill
- nacl-sa-architectSkill
- nacl-sa-domainSkill
- nacl-sa-featureSkill
- nacl-sa-finalizeSkill
- nacl-sa-flagsSkill
- nacl-sa-fullSkill
- nacl-sa-rolesSkill
- nacl-sa-ucSkill
- nacl-sa-uiSkill
- nacl-sa-validateSkill
- nacl-tl-conductorSkill
- nacl-tl-deliverSkill
- nacl-tl-deploySkill
- nacl-tl-dev-beSkill
- nacl-tl-dev-feSkill
- nacl-tl-devSkill
- nacl-tl-diagnoseSkill
- nacl-tl-docsSkill
- nacl-tl-fixSkill
- nacl-tl-fullSkill
- nacl-tl-hotfixSkill
- nacl-tl-intakeSkill
- nacl-tl-nextSkill
- nacl-tl-planSkill
- nacl-tl-qaSkill
- nacl-tl-reconcileSkill
- nacl-tl-regression-testSkill
- nacl-tl-releaseSkill
- nacl-tl-reopenedSkill
- nacl-tl-reviewSkill
- nacl-tl-shipSkill
- nacl-tl-statusSkill
- nacl-tl-stubsSkill
- nacl-tl-syncSkill
- nacl-tl-verify-codeSkill
- nacl-tl-verifySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 5 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Run the scripts in order.
- Distinctive: line 24
Read their JSON outputs.
- Distinctive: line 51
Run this first. Emit the messages verbatim on failure.
- Very specific: line 73
All subsequent commands use $NACL_HOME/nacl-migrate-ba/scripts/....
- Very specific: line 79
When invoked directly (i.e.
- Very specific: line 100
If the user passes --force, continue.
- Very specific: line 129
If --adapter was passed, skip this phase and use the user-provided value.
- Very specific: line 179
If --dry-run: stop here. Report the plan's summary to the user and exit.
- Distinctive: line 189
If it errors, stop and tell the user to start the Neo4j stack.
- Very specific: line 193
Read .nacl-migrate/ba-cypher.json.
- Distinctive: line 206
Stop execution. The partial graph is idempotent — rerunning after a fix will MERGE over the already-written nodes without duplicating.
- Very specific: line 227
Write the results to .nacl-migrate/ba-live-counts.json:
- Very specific: line 258
Write MIGRATION-REPORT-BA.md at project root.
- Very specific: line 299
All Neo4j writes are MERGE keyed on canonical IDs.
- Very specific: line 301
If the adapter or the source Markdown changes and yields a different canonical ID for a given source file, the old node becomes orphaned.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/nacl-migrate-ba — BA Markdown → Neo4j
Role
You delegate parsing, validation, and Cypher generation to stdlib Python
scripts under $NACL_HOME/nacl-migrate-ba/scripts/. You never parse
Markdown yourself; the scripts own that entirely. Your own job is:
- Run the scripts in order.
- Read their JSON outputs.
- Execute the Cypher plan against Neo4j via
mcp__neo4j__write-cypher. - Gather live counts via
mcp__neo4j__read-cypherand hand them toaudit_ba.py. - Present results and errors to the user in plain language.
The scripts produce structured JSON with status, error_code, message,
and remediation. When a script fails, print the message and remediation
verbatim.
Invocation
/nacl-migrate-ba [project_path] [--dry-run] [--adapter=<name>]| Parameter | Required | Description |
project_path | No | Project root (default: cwd). Must contain docs/. |
--dry-run | No | Run parse + validate + Cypher generation; skip all Neo4j writes and audit. |
--adapter | No | Force an adapter (inline-table-v1 | frontmatter-v1). Default: auto-detect. |
Prelude — locate NaCl home and verify Python
Run this first. Emit the messages verbatim on failure.
# Resolve $NACL_HOME
if [ -z "$NACL_HOME" ]; then
for candidate in "$HOME/projects/NaCl" "$HOME/NaCl" "$HOME/code/NaCl" "$HOME/src/NaCl"; do
if [ -f "$candidate/nacl-migrate-core/nacl_migrate_core/__init__.py" ]; then
export NACL_HOME="$candidate"
break
fi
done
fi
if [ -z "$NACL_HOME" ] || [ ! -f "$NACL_HOME/nacl-migrate-core/nacl_migrate_core/__init__.py" ]; then
echo "Unable to locate NaCl repo. Set NACL_HOME=/path/to/NaCl and retry." >&2
exit 1
fi
# Verify Python 3.11+
python3 -c 'import sys; sys.exit(0 if sys.version_info >= (3,11) else 1)' 2>/dev/null \
|| { echo "Python 3.11+ required. On macOS: brew install python@3.11"; exit 1; }All subsequent commands use $NACL_HOME/nacl-migrate-ba/scripts/....
Soft preflight (direct invocation)
When invoked directly (i.e. not via the /nacl-migrate orchestrator),
run a quick ID-pattern scan and warn — but do not block — if any token in
the project's filenames or YAML frontmatter does not match a known adapter
pattern. The orchestrator path runs the same scan at Phase A.5 with a
hard gate; this version is non-blocking so a single-layer rerun stays
ergonomic.
mkdir -p .nacl-migrate
python3 "$NACL_HOME/nacl-migrate-ba/scripts/preflight_ids.py" \
--project "$PWD" \
--output .nacl-migrate/preflight.json || trueExit code 1 from the script means unknown patterns were found. Surface
the report's patterns_unknown list to the user with this message:
Preflight surfaced N unknown ID-shaped tokens. These will likely be dropped at parse. Review
.nacl-migrate/preflight.jsonand either widen an adapter (recommended) or pass--forceto proceed anyway.
If the user passes --force, continue. Otherwise stop.
Preconditions
config.yamland.mcp.jsonexist at project root (produced bynacl-init).- Neo4j is reachable via
mcp__neo4j__get-schema— run it once before Phase 1 and stop if it errors. - At least one BA folder exists under
docs/. If none, skip this skill with: "No BA layer detected underdocs/. This project may be SA-only. Skippingnacl-migrate-ba."
Phase 0 — Detect adapter
python3 "$NACL_HOME/nacl-migrate-ba/scripts/detect_ba.py" \
--project "$PWD" \
--output .nacl-migrate/detect-ba.jsonRead the JSON.
status: "ok"+chosen: "<name>"+ambiguous: false→ proceed with that adapter.ambiguous: true→ show the candidate list to the user; ask them to pass--adapter=<name>.chosen: null+ambiguous: false→ no adapter matches; stop and ask the user to add a new adapter pernacl-migrate-core/README.md.reason: "no_ba_files_found"→ skip the skill (see preconditions above).status: "error"→ printmessage+remediationand stop.
If --adapter was passed, skip this phase and use the user-provided value.
Phase 1 — Parse Markdown → IR
python3 "$NACL_HOME/nacl-migrate-ba/scripts/parse_ba.py" \
--project "$PWD" \
--adapter "<chosen_adapter>" \
--output .nacl-migrate/ba-ir.jsonExpected stdout: a counts table and (optionally) a warnings tally. Confirm
warnings: 0 or surface each warning code to the user.
On error exit (code ≠ 0), surface message + remediation and stop.
Phase 2 — Validate IR
python3 "$NACL_HOME/nacl-migrate-ba/scripts/validate_ba_ir.py" \
--input .nacl-migrate/ba-ir.json \
--output .nacl-migrate/ba-validation.jsonValidator runs 10 checks (V1–V10) covering ID uniqueness, reference integrity, orphan states, source-file presence.
- Exit 0 → all pass, continue.
- Exit 1 → at least one check failed. Print the failure list from stdout and stop. If the user wants to proceed anyway, they must fix the IR or rerun with adapter adjustments.
Phase 3 — Generate Cypher plan
python3 "$NACL_HOME/nacl-migrate-ba/scripts/generate_ba_cypher.py" \
--input .nacl-migrate/ba-ir.json \
--output .nacl-migrate/ba-cypher.jsonPlan is an array of batches, each with cypher, params, kind (node or
edge) and label (human-readable). Batches are sized so one MCP call per
batch is sub-second.
If --dry-run: stop here. Report the plan's summary to the user and exit.
Phase 4 — Execute Cypher against Neo4j
Preflight:
mcp__neo4j__get-schema() # must succeedIf it errors, stop and tell the user to start the Neo4j stack.
Execute:
Read .nacl-migrate/ba-cypher.json. For each batch in batches, call:
mcp__neo4j__write-cypher(
query = batch.cypher,
params = batch.params
)Report progress per batch: [i/N] {label} rows={len(params.rows)} ok (or fail: <msg>).
On any batch failure:
- Log the batch index, label, and the Cypher error.
- Stop execution. The partial graph is idempotent — rerunning after a fix will MERGE over the already-written nodes without duplicating.
Phase 5 — Gather live counts
Query Neo4j via mcp__neo4j__read-cypher for every node label and
relationship type listed in audit_ba.py (keep this in sync — the script
declares canonical lists).
For each node label:
MATCH (n:{Label}) RETURN count(n) AS nFor each relationship type:
MATCH ()-[r:{TYPE}]->() RETURN count(r) AS nWrite the results to .nacl-migrate/ba-live-counts.json:
{
"nodes": {"BusinessProcess": 10, "WorkflowStep": 74, ...},
"relationships": {"CONTAINS": 10, "HAS_STEP": 74, ...}
}Batch the reads if convenient (single UNION query) — the shape of the
output file is the only hard requirement.
Phase 6 — Audit
python3 "$NACL_HOME/nacl-migrate-ba/scripts/audit_ba.py" \
--ir .nacl-migrate/ba-ir.json \
--counts .nacl-migrate/ba-live-counts.json \
--output .nacl-migrate/ba-audit.jsonExit 0 → "All counts match." — migration is clean. Exit 1 → at least one mismatch. Surface the mismatch list verbatim and ask the user to investigate before declaring migration complete.
Phase 7 — Report
Write MIGRATION-REPORT-BA.md at project root. Template:
# BA Migration Report
**Project:** {project_path}
**Adapter:** {adapter}
**Ran at:** {ISO timestamp}
## IR counts vs live Neo4j
| Node label | IR | Live | Status |
| ... | ... | ... | ... |
(Copy the table from ba-audit.json.)
## Relationships
| Type | IR | Live | Status |
| ... | ... | ... | ... |
## Warnings during parse
{list from ba-ir.json warnings[], or "none"}
## Validation
{summary from ba-validation.json: passed/failed, any failures}
## Next steps
- If audit is clean: proceed to `/nacl-migrate-sa` (if SA layer exists)
or continue to `/nacl-migrate` aggregation.
- If audit has mismatches: investigate each mismatched label via Cypher.
Rerun after fixes — writes are idempotent.Idempotency
- All Neo4j writes are
MERGEkeyed on canonical IDs; safe to re-run. - Re-detection and re-parse produce the same IR (modulo timestamps).
- If the adapter or the source Markdown changes and yields a different
canonical ID for a given source file, the old node becomes orphaned.
audit_ba.pydetects this as a count mismatch — investigate rather than auto-delete.
Error handling summary
| Situation | Response |
Prelude can't find $NACL_HOME | Stop. Ask user to export NACL_HOME. |
| Python < 3.11 | Stop. Ask user to upgrade. |
| Adapter unknown / ambiguous | Stop. Present candidates. |
| Parse warnings | Continue. Surface tally to user. |
| Validation failure | Stop. Print failed checks. |
| Neo4j unreachable | Stop before any write. |
| Individual batch failure | Stop after that batch; partial writes are safe to resume. |
| Audit mismatch | Report. Do not claim success. |
Reads / Writes
Reads
{project}/docs/**/*.mdmcp__neo4j__get-schema(preflight)mcp__neo4j__read-cypher(live counts in Phase 5)
Writes
{project}/.nacl-migrate/detect-ba.json{project}/.nacl-migrate/ba-ir.json{project}/.nacl-migrate/ba-validation.json{project}/.nacl-migrate/ba-cypher.json{project}/.nacl-migrate/ba-live-counts.json{project}/.nacl-migrate/ba-audit.json{project}/MIGRATION-REPORT-BA.mdmcp__neo4j__write-cypher(Phase 4)
Checklist
- Prelude:
$NACL_HOMEresolved, Python 3.11+ present - Phase 0: adapter detected or user supplied
- Phase 1: IR emitted, zero warnings (or tally surfaced)
- Phase 2: V1–V10 all pass
- Phase 3: Cypher plan generated
- Phase 4: every batch executed via
mcp__neo4j__write-cypher - Phase 5: live counts gathered
- Phase 6: audit clean
- Phase 7:
MIGRATION-REPORT-BA.mdwritten
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

