skills/graphwiki/SKILL.md
Agent-first graph-backed knowledge wiki builder with a self-contained CLI. Use for Graphwiki init/build/ingest/update, source indexing, semantic entity and relationship extraction, generated wiki pages, graph JSON/HTML explorer, evidence line ranges, query/explain question answering, synthesis pages, HTML reports, adding confirmed entity types, applying patches, cleanup, validation, tasks, and SQLite cache generation.
npx skillsauth add cyberelf/agent_skills graphwikiInstall 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.
Graphwiki builds and maintains a graph-backed knowledge wiki without installing a separate package. This skill contains the CLI at graphwiki.py and the bundled Python package under tool/.
Use this skill when the user asks to initialize, build, ingest, update, query, explain, answer from, report on, clean up, validate, cache, or extend a Graphwiki knowledge base. The user-facing entrypoint is the skill/agent, not the script; graphwiki.py is the internal executor that the skill calls after the agent decides what workflow is appropriate.
Users should ask the agent for operations such as "initialize this knowledge base", "update changed documents", "extract entities and build wiki pages", "query a concept relationship", or "generate an HTML report". The agent then selects the workflow and internally calls the bundled executor:
python /path/to/this/skill/graphwiki.py --root <project-root> <command>
Do not make the script the user's primary interface. The agent owns skill discovery, path substitution, command selection, and execution.
When this skill is loaded, the agent should quickly inspect the current repository state and tell the user what kinds of requests are available:
.graphwiki/graph.json is missing: suggest requests such as "initialize and build the knowledge base" or "index the documents under source/."source/ exists but the graph has no semantic entities or wiki pages: suggest "extract entities and relationships concurrently and build wiki pages.".graphwiki/GRAPH_REPORT.md or tasks next shows pending/stale/orphaned/needs_update work: suggest "process pending tasks," "repair stale evidence," or "update affected pages."The schema/ subdirectory is the semantic extension point for this skill. Read schema/README.md before creating or changing semantic outputs.
schema/wiki-page.schema.md defines the richer wiki page structure for entity and synthesis pages.schema/html-report-schema.md defines the semantic report contract, including the required report.spec.json shape used before rendering standalone HTML reports.schema/query-schema.md defines the built-in query modes and when to use question_answer versus html_report.Project-local schema under .graphwiki/schema/ may narrow these contracts, but it must not weaken source provenance or allow wiki pages to become source evidence.
Graphwiki has four primary application scenarios. Keep them separate when deciding what to do next. All four scenarios rely on the shared rules in Entity and Relationship Extraction Rules and Tool Usage Contract.
Use this when the user starts a new knowledge base or asks for a full first build from an existing source/ corpus.
source/. Do not put generated wiki pages into source/.init, then build. This creates deterministic project state: source document nodes, collection nodes, hashes, source views, schemas, reports, graph explorer, and build-time community_id assignments. Re-running build preserves existing semantic entities, wiki page nodes, relationships, and evidence edges..graphwiki/entities/schema.json, .graphwiki/entities/concept.md, .graphwiki/entities/synthesis.md, and any project-specific entity type docs.entity-types recommend to get deterministic candidate type suggestions from source/. Use the tool question UI to ask the user which suggested types to confirm; only then run entity-types add ... --confirmed.tasks next and tasks claim when pending actions exist or when multiple subagents can process independent source groups.prompts/entity_extractor.md template. Fill in the {{...}} placeholders (project root, graph hash, entity types, batch name, source list, output path). Each sub-agent reads its source documents and writes one patch JSON to .graphwiki/patches/.apply. After each apply, the graph hash changes — always read the current hash from .graphwiki/graph.json before applying the next patch. The main agent must not parallelize apply.validate-wiki --strict, inspect .graphwiki/GRAPH_REPORT.md, use stats to inspect communities and hub nodes, and open .graphwiki/graph.html when a visual audit is useful.Use this when source documents are added, modified, moved, renamed, or deleted.
update first. This refreshes file hashes, Merkle state, source views, source document nodes, reports, and pending actions while preserving existing semantic nodes..graphwiki/GRAPH_REPORT.md, .graphwiki/graph.json indexes, and tasks next to identify new documents, changed documents, stale evidence, orphaned entities, or needs_update pages.cleanup. Then update affected wiki pages by patch: remove unsupported claims, mark pages orphaned when no source evidence remains, or mark needs_update when remaining evidence still supports a narrower version.stale_evidence and leave an explicit pending item.validate-wiki --strict and inspect the report again. Do not treat ingest as finished while source changes have unresolved stale, orphaned, or missing-evidence actions.Use this when the user needs a new semantic object type, such as product, component, policy, application, scenario, capability, or decision record.
entity-types add ... --confirmed. If it does not, use the existing concept type instead..graphwiki/entities/<type>.md after command generation. Fill in recognition boundaries, examples, counterexamples, fields, and relationship rules so future extraction is consistent.update if needed so entity config changes queue extraction work across existing source documents.tasks claim or a scoped source list to extract the new type from existing documents. Apply the shared extraction rules, but only create entities that match the new type boundary.apply; do not invent or add entity types during extraction.validate-wiki --strict and inspect the report for duplicates with existing concept pages. Merge or alias duplicates instead of leaving parallel pages for the same thing.Use this when the user asks a question about the knowledge base.
schema/query-schema.md. Use question_answer for normal answers and optional synthesis. Use html_report when the user asks for a report, dashboard, briefing, audit output, or shareable HTML artifact.query or explain before reading broad files. query supports multi-keyword matching, --match all|any, --fuzzy, --include-source, --semantic-only, and optional --traverse bfs|dfs. Use returned entity IDs, wiki paths, source paths, and line ranges as the navigation plan.source/ or .graphwiki/source_views/ when the answer depends on provenance.neighbors <node> for directly related nodes, path <source> <target> for shortest semantic paths, and stats for communities, hub nodes, isolated semantic nodes, and graph overview. Query-like commands support --semantic-only when source_document/wiki_page/collection nodes must be excluded from resolution or ranking; use --include-structural when structural nodes are needed.question_answer, return a concise answer with relevant entities, relationships, source paths, and line ranges. Separate confirmed source-backed facts from inference or gaps.question_answer result should become reusable knowledge, spawn a sub-agent using prompts/query_agent.md (or do it inline) to create a synthesis entity and wiki page by patch. The synthesis page must follow schema/wiki-page.schema.md.html_report, first draft a report spec that follows schema/html-report-schema.md: title, query, audience, source scope, sections, evidence, visuals, rendering options, and the required report.spec.json contract. Then render the report under output/reports/<report-id>/ with index.html as the default entry file. Do not write report artifacts under wiki/ or .graphwiki/.synthesis patch; do not rely on the HTML report as the canonical knowledge layer.When spawning sub-agents for parallel extraction or query work, use the templates in prompts/:
prompts/entity_extractor.md — batch entity extraction. Each sub-agent owns one non-overlapping batch of source documents and writes one patch JSON.prompts/query_agent.md — question answering with optional synthesis patch.prompts/html_report_generator.md — HTML report generation using schema/html-report-schema.md, writing only under output/reports/<report-id>/.prompts/README.md — placeholder reference and workflow pattern.These templates encode the canonical patch schema, quote-matching rules, wiki frontmatter requirements, and known anti-patterns. Use them with the contracts in schema/ — they exist because freeform prompts produced schema drift and quote mismatches in past runs.
These rules are shared by init, ingest, add_entity, and query synthesis work.
type:stable-slug, for example concept:source-view or synthesis:architecture-overview..graphwiki/entities/schema.json. If a candidate suggests a new type, stop and ask for user confirmation; do not add the type or emit patch entities with that type during extraction.source_document evidence block with exact start_line, end_line, and preferably an exact quote.aliases for alternate names, abbreviations, spelling variants, and translated names.draft when the entity is plausible but the evidence boundary is weak. Use needs_update when a changed source affects an existing page. Use stale_evidence only after evidence no longer validates.depends_on, implements, contradicts, supersedes, part_of, uses, causes, or configured project-specific relations.## 关系 section.schema/wiki-page.schema.md when writing wiki.content for new or updated pages.wiki.content is omitted, apply writes a default page template. If wiki.content is provided, it must include valid frontmatter and the standard sections because the CLI writes it verbatim.apply rewrites the page for every entity included in the patch, so include merged wiki.content when changing an existing page.## 定义, ## 关键事实, ## 关系, ## 证据引用, and ## 待更新事项; the schema adds richer sections such as ## 摘要, ## 范围与边界, ## 冲突与不确定性, and ## 变更记录.wiki/ pages as source evidence; evidence must come from source/ or its source views.build and stopping, leaving only source document nodes with no semantic entities.apply normalizes and repairs common sub-agent mistakes so that one bad quote does not abort the whole patch. Knowing what it tolerates helps you avoid spending tokens on shapes that get rewritten anyway, and knowing the limits keeps you from depending on the tolerance:
name is accepted as label, summary as definition, and flat source_documents/source_document lists are converted to the canonical evidence array. Still prefer the canonical names — they survive future schema tightening.quote is not a verbatim substring of lines[start_line-1 : end_line], the loader retries by stripping markdown link syntax, then searches a ±20-line window, then falls back to longest-fragment matching. Each repair emits a warning: line in the apply output; if all fallbacks fail, the quote is dropped (the range is kept). A dropped quote means the entity loses provenance — fix it in the next patch.validate-wiki accepts both entity_id: <id> and id: <id> in the page frontmatter. New pages should use entity_id: to match the default template.Tolerances exist for resilience, not as a substitute for reading the source. The sub-agent prompts in prompts/ describe the canonical shape — follow them.
build and update are deterministic indexing commands. They do not perform LLM extraction, entity merging, relationship selection, or wiki prose synthesis.build assigns graph communities deterministically. If networkx is installed, it uses networkx modularity communities; otherwise it falls back to connected components while keeping the CLI usable.source/ is the raw document corpus and the only source evidence root. wiki/ is generated knowledge and must not be used as source evidence..graphwiki/source_views/ contains stable text views for source documents. Read these when query output points there. Markdown/text line numbers refer directly to source text; PDF/DOCX line numbers refer to the stable source view, with optional original locators in sidecar maps..graphwiki/source_views/*.map.json is generated only when a source format has meaningful original locators, such as PDF pages or DOCX paragraphs/table rows.output/reports/<report-id>/ is the only default location for generated HTML reports. Reports are user-facing artifacts, not graph state and not source evidence.tasks next and tasks claim to split pending extraction work across subagents. Subagents produce patches; the main agent applies them serially..graphwiki/graph.json directly. Use patch JSON plus apply.python graphwiki.py --root . init
python graphwiki.py --root . build
python graphwiki.py --root . update
python graphwiki.py --root . query "term"
python graphwiki.py --root . query "agent feedback" --match all --fuzzy --semantic-only --traverse bfs --depth 2
python graphwiki.py --root . explain "concept:example" --semantic-only
python graphwiki.py --root . neighbors "concept:example" --target-type concept --semantic-only
python graphwiki.py --root . path "concept:a" "concept:b" --semantic-only
python graphwiki.py --root . stats --semantic-only --type concept
python graphwiki.py --root . entity-types list
python graphwiki.py --root . entity-types recommend
python graphwiki.py --root . entity-types add "decision record" --confirmed --description "Architecture decisions with evidence" --field decision --relation supersedes
python graphwiki.py --root . schema patch
python graphwiki.py --root . apply patch.json
python graphwiki.py --root . cleanup
python graphwiki.py --root . validate-wiki
python graphwiki.py --root . validate-wiki --strict
python graphwiki.py --root . sqlite build
Patches are the only supported way to add semantic entities from Agent work:
{
"patch_id": "agent-run-001",
"base_graph_hash": "current graph hash from .graphwiki/graph.json",
"entities": [
{
"id": "concept:example",
"type": "concept",
"label": "Example",
"definition": "Short definition written by the Agent.",
"evidence": [
{
"source_document": "source/example.md",
"ranges": [
{
"start_line": 10,
"end_line": 14,
"quote": "Exact text that must appear in that range.",
"confidence": 1.0
}
]
}
]
}
]
}
The CLI validates patch shape, source paths, line ranges, quotes, and configured entity types before writing the graph or wiki page. The generated schema path is .graphwiki/schemas/patch.schema.json.
.graphwiki/graph.json: canonical JSON database..graphwiki/GRAPH_REPORT.md: Agent audit report and pending actions..graphwiki/graph.html: self-contained graph explorer with search, filters, node details, evidence, and pending actions..graphwiki/schemas/patch.schema.json: JSON Schema for Agent patches..graphwiki/sqlite/graphwiki.sqlite: optional derived query cache.output/reports/<report-id>/index.html: generated HTML report output for html_report query mode.wiki/: generated entity and synthesis pages.development
Use when the user asks to export a local HTML file, web page, or invitation page to a single-page PDF, a no-pagination PDF, a long PDF with auto-calculated height, or a PDF without headers and footers. Trigger on phrases like 单页 PDF, 不分页, 自动计算长度, 长图 PDF, 去掉页眉页脚, export HTML to single-page PDF, or print page to one PDF page.
development
Build and expand an insight-ready raw-material layer by discovering page-level sources, deduplicating them with an internal pre-crawl link index, capturing raw Markdown, verifying metadata in place, and keeping ingest/register state aligned. Use for additive source harvesting, raw webpage capture, source registry maintenance, source/ingest tracking, source/raw downloads, and in-place verification rather than final synthesis.
development
Generate a structured, illustrated Q&A HTML document from the current conversation. Scans the conversation for conceptual questions the user asked and Claude's answers, then produces a self-contained HTML file with styled cards and SVG diagrams for technical/architectural topics. If a Q&A HTML file already exists in the current project directory, appends the new Q&As to it instead of creating a new file. Trigger this skill whenever the user asks to "generate Q&A", "create Q&A from conversation", "save Q&A", "document our Q&A", "turn this chat into Q&A", or anything suggesting they want the conversation's questions and answers captured as a document — even if they don't use the exact phrase "Q&A skill".
testing
Create high-quality draw.io diagrams with better layout for architecture diagrams, flowcharts, block diagrams, system maps, data flows, and complex connection-heavy visuals. Use when draw.io routing becomes messy, edges overlap, blocks cross too much, or the user wants cleaner diagram layout than the default drawio skill.