with one click
science-update-graph
// Re-audit and re-materialize the knowledge graph after canonical source changes.
// Re-audit and re-materialize the knowledge graph after canonical source changes.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | science-update-graph |
| description | Re-audit and re-materialize the knowledge graph after canonical source changes. |
Converted from Claude command /science:update-graph.
Before executing any research command:
Resolve project profile: Read science.yaml and identify the project's profile.
Use the canonical layout for that profile:
research → doc/, specs/, tasks/, knowledge/, papers/, models/, data/, code/software → doc/, specs/, tasks/, knowledge/, plus native implementation roots such as src/ and tests/Load role prompt: .ai/prompts/<role>.md if present, else references/role-prompts/<role>.md.
Load the science-research-methodology and science-scientific-writing Codex skills. If native skill loading is unavailable, use codex-skills/INDEX.md to map canonical Science skill names to generated skill files and source paths.
Read specs/research-question.md for project context when it exists.
Load project aspects: Read aspects from science.yaml (default: empty list).
For each declared aspect, resolve the aspect file in this order:
aspects/<name>/<name>.md — canonical Science aspects.ai/aspects/<name>.md — project-local aspect override or additionIf neither path exists (the project declares an aspect that isn't shipped with
Science and has no project-local definition), do not block: log a single line
like aspect "<name>" declared in science.yaml but no definition found — proceeding without it and continue. Suggest the user either (a) drop the
aspect from science.yaml, (b) author it under .ai/aspects/<name>.md, or
(c) align the name with one shipped under aspects/.
When executing command steps, incorporate the additional sections, guidance, and signal categories from loaded aspects. Aspect-contributed sections are whole sections inserted at the placement indicated in each aspect file.
Check for missing aspects: Scan for structural signals that suggest aspects the project could benefit from but hasn't declared:
| Signal | Suggests |
|---|---|
Files in specs/hypotheses/ | hypothesis-testing |
Files in models/ (.dot, .json DAG files) | causal-modeling |
Workflow files, notebooks, or benchmark scripts in code/ | computational-analysis |
Package manifests (pyproject.toml, package.json, Cargo.toml) at project root with project source code (not just tool dependencies) | software-development |
If a signal is detected and the corresponding aspect is not in the aspects list,
briefly note it to the user before proceeding:
"This project has [signal] but the
[aspect]aspect isn't enabled. This would add [brief description of what the aspect contributes]. Want me to add it toscience.yaml?"
If the user agrees, add the aspect to science.yaml and load the aspect file
before continuing. If they decline, proceed without it.
Only check once per command invocation — do not re-prompt for the same aspect if the user has previously declined it in this session.
Resolve templates: When a command says "Read .ai/templates/<name>.md",
check the project's .ai/templates/ directory first. If not found, read from
templates/<name>.md. If neither exists, warn the
user and proceed without a template — the command's Writing section provides
sufficient structure.
Resolve science CLI invocation: When a command says to run science,
prefer the project-local install path: uv run science <command>.
This assumes the root pyproject.toml includes science as a dev
dependency installed via uv add --dev --editable "$SCIENCE_TOOL_PATH"
(the distribution is science; the entry point it installs is science).
If that fails (no root pyproject.toml or science not in dependencies),
fall back to:
uv run --with <science-plugin-root>/science science <command>
Prerequisite: Read
docs/specs/2026-03-01-knowledge-graph-design.mdanddocs/proposition-and-evidence-model.mdbefore starting.
This command updates the graph by changing canonical source files, not by editing triples directly. The workflow is: detect source changes, fix any unresolved references, then re-materialize knowledge/graph.trig.
All science commands below use this pattern:
uv run science <command>
For brevity, the examples below write just science <command>; always expand them to uv run science <command> when executing.
When adding new entities as part of the update, the cross-project registry is consulted during graph build to detect potential duplicates across projects. If matches are found, prefer reusing existing canonical IDs and aliases from the registry.
Run:
science graph diff --mode hybrid --format json
Review the output. If no files are stale, report "Graph is up to date" and stop.
Typical categories:
specs/ or doc/tasks/knowledge/sources/<local-profile>/For each stale source:
related, source_refs, and task links to canonical IDs.theme:<slug> for durable cross-cutting organizing frames. Do not use topic:<slug> for new semantic authoring; use concept for atomic vocabulary and theme for the project-level lens that organizes other entities.Use a fix-on-touch policy for legacy entity IDs encountered during the update: when a stale source already requires editing, apply the safe rename/xref addition needed to move it toward canonical identity instead of leaving known legacy references behind.
Run:
science graph migrate --project-root . --format json
science graph audit --project-root . --format json
Use graph migrate first as a dry-run audit. It previews alias-resolvable rewrites, layered-claim
migration gaps, and projected cleanup without mutating the project.
If the preview looks correct, re-run with:
science graph migrate --project-root . --format json --apply
Only --apply writes alias rewrites, scaffolds local-profile source files, and persists
knowledge/reports/kg-migration-audit.json. If unresolved references remain after the audit or
apply pass, fix the upstream sources first. Do not build until the audit is clean.
Run:
science graph build --project-root .
science graph validate --format json
science graph stats --format json
If the update involved legacy ID cleanup or new project-local semantics, keep the migration artifacts current:
knowledge/sources/<local-profile>/entities.yamlknowledge/sources/<local-profile>/mappings.yamlknowledge/reports/kg-migration-audit.jsongraph.trig is always regenerated.<local-profile> comes from science.yaml knowledge_profiles.local and defaults to local.graph diff reports staleness after a rebuild, inspect the source file change rather than patching the graph output.