Wiki

From theafh/ai-modules · View interactive version

Wiki is an AI agent skill from the GitHub repository theafh/ai-modules. Build and maintain a persistent, compounding knowledge base of interlinked plain markdown files. Use when the user asks to create, build, start, or initialize a wiki or knowledge base; add, create, or write wiki pages; query, compare, contrast, reference, or analyze an existing wiki to answer a rese

How to use this skill

Skill file

Wiki

<wiki>

<role>

This LLM-Wiki is managed by the wiki skill, created by Andreas F. Hoffmann.

Unlike traditional RAG (which rediscovers knowledge from scratch per query),

the wiki compiles knowledge once and keeps it current. Cross-references are

already there. Contradictions have already been flagged. Synthesis reflects

everything ingested.

Division of labor: the human curates sources and directs analysis. The

agent summarizes, cross-references, files, and maintains consistency.

</role>

<orient_first_top>

**Read $WIKI/SCHEMA.md once at the start of any session that activates this

skill.** The schema declares the domain, the page-type enum, the tag taxonomy,

and the conventions every subsequent action must honor. Reading it first

prevents wrong-type pages, off-taxonomy tags, and duplicate or misfiled work.

The full orientation pass (SCHEMA + index + recent log) is covered in

<resuming_an_existing_wiki>; this top-line note exists so the SCHEMA read is

never skipped, even on quick queries.

</orient_first_top>

<when_to_activate>

Use this skill when the user:

</when_to_activate>

<architecture>

Three layers carry the wiki:

wiki/
├── SCHEMA.md           # Conventions, structure rules, domain config
├── index.md            # Sectioned content catalog with one-line summaries
├── log.md              # Chronological action log (append-only in substance, rotated yearly)
├── raw/                # Layer 1: Immutable source material
│   ├── articles/       # Externally-published articles, web clippings
│   ├── papers/         # PDFs, arxiv papers
│   ├── meetings/       # Meeting notes, interviews, spoken-word transcripts (podcasts, talks)
│   ├── notes/          # Internal memos, discussion writeups, ad-hoc observations, internal docs not published externally
│   └── assets/         # Images, diagrams referenced by sources
├── entities/           # Layer 2: Entity pages (people, orgs, products, models)
├── concepts/           # Layer 2: Concept/topic pages
├── comparisons/        # Layer 2: Side-by-side analyses
├── queries/            # Layer 2: Filed query results worth keeping
├── summaries/          # Layer 2: Standalone overview / digest pages
└── procedures/         # Layer 2: Procedure / workflow / how-to pages

The log is append-only in substance. Never reword, reorder, or delete what

a past entry records. An entry may still be edited to repair a structural or

lint break it introduced, keeping what it records and where it sits. See

<appending_to_log> for the rule, and <lint_and_audit> for the duplicate

heading the linter surfaces.

Layer 1: Raw Sources. Immutable. The agent reads but never modifies these.

Layer 2: The Wiki. Agent-owned markdown files. Created, updated, and

cross-referenced by the agent. Page types split into declarative (what / why)

and procedural (how). See <page_types> below.

Layer 3: The Schema. SCHEMA.md defines structure, conventions, and tag

taxonomy. The linter reads its ## Frontmatter yaml block to learn the

page-type enum, so wikis can declare additional types there without modifying

the linter.

<folder_layout>

The folder tree is the type axis only. Every page lives directly at

<pluralized-type>/<slug>.md, flat, one layer deep. No thematic prefix

(themes/ai/concepts/foo.md is wrong), no sub-folder nesting inside a type

folder (concepts/ai/foo.md is wrong), no bare files at the wiki root.

Thematic scope belongs in tags: and type:, not in folder names, because tags have

an enumerated taxonomy in SCHEMA.md and don't drift the way emergent theme

folders do. The linter's structure check enforces this with blocking

severity on misfiled pages (with a concrete move suggestion) and warn

when an expected type folder is missing on disk. Because the wiki's primary

consumer is an LLM with tools that greps and follows links rather than

browsing, visual folder shelving adds no real value and trades it for

filing-drift risk.

The slug is pure ASCII; the content keeps its own language. A wiki may be

authored in any language. Page bodies, headings, and the title: frontmatter

field use the language of the content, so title: Künstliche Evolution is

correct. The slug stays pure ASCII, because the filename is the one path every

clone and every tool compares byte-for-byte, and an NFC/NFD mismatch between

machines turns one page into a delete-plus-add. Transliterate a

content-language word into its ASCII form rather than embedding the character:

German folds ä→ae, ö→oe, ü→ue, ß→ss, so the title

Künstliche Evolution gets the slug kuenstliche-evolution.md; every other

language strips diacritics (é→e, ñ→n, å→a). A naive Unicode→ASCII fold

would wrongly produce u/o/a for the German umlauts, so apply the German

map before stripping. The linter's filename check warns on any non-ASCII

page or raw/ sidecar filename and suggests the folded slug.

</folder_layout>

</architecture>

<page_types>

Each page type answers a different shape of question. Pick by the entry

point you (or a future operator) will re-find the page from.

| Type | Answers | When to use |

| --- | --- | --- |

| entity | "Who/what is X?" | A single named person, org, product, model, or place that has identity. |

| concept | "What does X mean, and why?" | An idea, mechanism, or technique that's describable on its own. |

| comparison | "How does X compare to Y?" | Side-by-side with dimensions and a verdict. |

| summary | "What's the overview of topic X?" | Topic-organized digest. Re-found by browsing the topic. |

| query | "What's the answer to my specific question?" | Question-organized synthesis. Re-found by re-asking. |

| procedure | "How should X be done?" | An evergreen rule, convention, or workflow. The page holds the rule; the instance that prompted it lives elsewhere. |

<declarative_vs_procedural>

Declarative vs procedural: the load-bearing split. Entity, concept,

comparison, summary, and query capture what is true and why (subject

knowledge). procedures/ captures how to act and *how things should be

organized* (operational knowledge: workflows, conventions, runbooks, build

steps, sourcing rules, review checklists, naming rules). A wiki without

procedure pages is a research notebook; a wiki without the declarative types

is just a runbook collection. Most projects need both.

</declarative_vs_procedural>

<summary_vs_query>

summary vs query. Same content, different framing. Topic-organized →

summary. Question-organized → query. When both work, prefer summary for its

broader entry surface. File as query only when the question shape itself

is what makes the answer valuable.

</summary_vs_query>

<procedure_vs_concept>

procedure vs concept. Both page types can answer "how"

questions, but they answer different ones:

reader walks away understanding a feature, mechanism, or design

choice the project implements. Concept pages can be deeply

technical, can discuss how the system was built and why it was

designed a certain way, and can carry rules that constrain

authors. Those rules describe properties of the system

("errors must live in a closed set", "module folders contain

main.mdl"); they are facts about how the project is built,

not actions a contributor performs.

Y?" The reader walks away with the sequence of actions needed

to accomplish a specific task. Procedure pages are action lists:

open this file, add this variant, implement these methods, run

this test.

"How transformers attend" (how does X work → concept) vs "How to

add a new training run" (how do I do X → procedure). Both contain

"how". The first describes the system; the second prescribes an

action sequence.

The trap: a page about how the system works can wear imperative

voice and operator-facing scaffolding (trigger lists, "must"

bullets, pitfalls) and still be a concept. Authorial rules that

describe system properties belong on concept pages even when they

constrain author behavior. A procedure page is the one that lists

the actual steps a contributor takes (open file X, add variant Y,

run command Z). If you are not writing those steps, you are not

writing a procedure.

Test before you file. Write the question the page answers. "How

does X work?" or "What is X?" → concept. "How do I do X?" or

"What do I do when Y?" → procedure. If the answer to "how does

this page help me?" is "I now understand how the system works",

that is a concept; if the answer is "I now know the steps to

take", that is a procedure.

</procedure_vs_concept>

<page_anatomy>

Page anatomy. Once the type is picked, write the sections in this order:

| Type | Sections (in order) |

| --- | --- |

| entity | Overview · Key facts and dates · Relationships to other entities |

| concept | Definition / explanation · Current state of knowledge · Open questions or debates · Related concepts |

| comparison | What is being compared and why · Dimensions (table preferred) · Verdict / synthesis |

| summary | Topic and scope · Key findings by sub-topic · Open threads |

| query | Question (verbatim, as the page title) · Synthesized answer with cross-links · Confidence and caveats |

| procedure | One-paragraph rule summary · When this applies (the trigger) · The rule · Pitfalls / edge cases (optional, rule-shaped only) · See Also |

Cross-links go in every section that references another wiki page. The object

being attributed picks the channel. A source the wiki captured under raw/ is

cited inline next to the claim it supports, as a standard-markdown link rather

than a footnote marker, and is listed in the page's sources: frontmatter, whose

raw/<kind>/<slug>.md paths the lint validates against disk (see

<write_or_update_pages>). A live in-repo document that is the subject of

classification (a paper, spec, or codebase the wiki exists to explain) is cited

the same way under a root the wiki declares with a Declared source root:

bullet in SCHEMA.md's ## Lint section; it carries no sha256 drift detection,

so its coherence relies on a review rule the wiki states. The sources: field

is present on a page citing a captured raw source or a declared-root document

and absent from a page citing neither, so a wiki that captures nothing and

declares no root carries no sources: key rather than an empty list everywhere.

Uncaptured lineage that is not the subject of classification (e.g. doctrine

in another repo) goes into an optional ## Derived from body section at the

page bottom; the renamed heading does not match the linter's deprecated

## Sources regex, so it does not collide with the structured sources:

channel.

</page_anatomy>

</page_types>

<tools>

Three bundled scripts handle discovery, init, and lint. Every one of them

runs from $WIKI_SKILL, resolved through <resolve_wiki_skill_bundle> below

before the first of these calls. **Always run

"$WIKI_SKILL/scripts/discover_wiki.sh" first**, and never resolve the wiki path

with your own inline Python or shell logic; the script is the single source of

truth for walk-up semantics, and bypassing it is what causes silent upstream

adoptions.

# Exit codes: 0 = resolved path on stdout, 1 = that path is missing on
# disk, 2 = ambiguous with candidates on stdout, 3 = usage error. Only 2
# starts the ask-the-user protocol; 1 and 3 are hard failures the `*)`
# branch passes straight out.
if output=$("$WIKI_SKILL/scripts/discover_wiki.sh"); then
    WIKI="$output"                                    # auto-resolved
else
    rc=$?
    case $rc in
        2) candidates="$output" ;;                    # ambiguous → ASK USER
        *) exit "$rc" ;;                              # 1 = missing, 3 = usage
    esac
    # On exit 2, follow <resolving_the_wiki_location> below before
    # touching any wiki file. Do not pick a candidate yourself.
fi
[[ -d "$WIKI" ]] || "$WIKI_SKILL/scripts/init_wiki.sh" "$WIKI"  # scaffold if missing
python3 "$WIKI_SKILL/scripts/lint.py"                           # health-check

<resolve_wiki_skill_bundle>

Canonical statement of how any artefact in this family locates $WIKI_SKILL,

the installed wiki skill bundle holding SKILL.md, scripts/, and

references/. Siblings cite this block by tag instead of restating the order,

and that covers the front-end skills and the auto_shaper_wiki agent alike.

Resolve $WIKI_SKILL as run-local orientation state before the first bundled

tool call, and resolve it before $WIKI, because discovery itself runs from

this bundle.

Take the first candidate that validates, in this order:

  1. The active artefact's own directory, when the harness exposes the agent

or skill path it loaded. Every agentic IDE that surfaces a skill exposes

that path. From skills/wiki_import/ or skills/wiki_wrapup/ the sibling

hub is ../wiki, and from agents/auto_shaper_wiki.md it is

../skills/wiki.

  1. A sibling wiki skill directory in the same installed plugin bundle or

local plugin checkout as the active artefact.

  1. A deployed user-skill location, such as ~/.claude/skills/wiki or

~/.codex/skills/wiki, following symlinks when present.

  1. A bounded search under the agent configuration roots this plugin

deploys into (~/.claude/skills, ~/.codex/skills, and the plugin cache

roots beneath them such as ~/.codex/plugins/cache/) and the current

repository checkout. Never run an unbounded find /.

Accept a candidate only when every required asset exists inside it:

When no candidate validates, stop and report that the wiki skill bundle could

not be resolved, naming the roots already tried. This order exists to prevent

one specific failure. The working directory is the user's project, so guessing

a scripts/ directory from there finds that project's own scripts or nothing.

Keep the resolved value run-local, as a shell variable inside the block that

uses it or in the session's orientation notes. A new session, repository,

worktree, plugin cache, or harness can legitimately change it, so user-level

environment variables, startup hooks, plugin configuration, and cross-session

caches all go stale. Quote every expansion, as in

"$WIKI_SKILL/scripts/lint.py", so a bundle path containing spaces still

resolves.

</resolve_wiki_skill_bundle>

<discover_wiki>

discover_wiki.sh recognises a directory as a wiki when its basename contains

"wiki" (case-insensitive) and at least two of SCHEMA.md / index.md /

log.md exist directly inside it and it carries no .no_wiki. (A fresh

wiki has all three markers, so the 2-of-3 rule still resolves one that lost a

marker; a directory merely named wiki without markers is not adopted.)

It resolves in this order:

  1. CWD short-circuit. If the current working directory is itself a

recognised wiki, print it and stop, before any walk-up. This covers

standing inside a wiki, including a topic-named one like ml-wiki/.

  1. Walk up level by level from CWD toward $HOME. At each level:

record as the existing wiki and STOP walking (the search never crosses

an existing wiki). A second matching sibling at the same level is not

surfaced.

The script auto-resolves on stdout (exit 0) when it can:

holds a recognised wiki → print that path.

$HOME/wiki (the explicit "use the global wiki" chain).

Otherwise the script exits 2 and lists every candidate in walk order on

stdout, one per line, prefixed with its kind:

AVAILABLE:/Users/foo/projects/myproject/src
AVAILABLE:/Users/foo/projects/myproject
AVAILABLE:/Users/foo/projects
EXISTING:/Users/foo/wiki        # only as the last entry, if found

When CWD is not at or under $HOME, walk-up is disabled and the script

falls back to the pre-walk-up behavior (a recognised wiki child of CWD,

./.no_wiki, or ask).

Two more exit codes complete the set. Exit 1 says the resolved path does

not exist on disk: --check reports it for an auto-resolved path, and a

given WIKI_PATH reports it for itself. Exit 3 is a usage error, an

unknown flag or an unsupported argument shape, with the message on stderr and

nothing on stdout; it carries no candidate list, so it stays a hard failure

rather than an ambiguity prompt.

Passing a WIKI_PATH positionally skips discovery and answers for that path

alone: an existing directory prints its canonical path and exits 0, a missing

one exits 1, and the wiki predicate stays out of it. That is how a caller

hands back the $WIKI that <proceed_with_operation> settles from a pick.

For an AVAILABLE: pick that path exists only after init_wiki.sh scaffolds

it, and a positional call before then exits 1. Re-running bare discovery

against a choice would only reproduce the same exit-2 list. lint.py takes

the same path as its optional positional argument.

.no_wiki is the explicit opt-out and overrides the predicate: drop an empty

file by that name in any directory you do not want a local wiki for, and the

walk skips that level. Place it at an existing <wiki-path>/.no_wiki to retire

that wiki dir without deleting it; discovery then declines to adopt it.

</discover_wiki>

<init_wiki>

init_wiki.sh materializes SCHEMA.md, index.md, log.md, and the

standard directory tree from canonical templates in

references/template_schema.md, template_index.md, template_log.md. It

refuses to overwrite an established wiki. To customize the schema beyond the

placeholders, read references/template_schema.md for the full annotated

template (domain, tag taxonomy, page-type sections, update policy).

</init_wiki>

<lint>

lint.py reads the page-type enum from SCHEMA.md's ## Frontmatter yaml

block, so wikis can extend the type set in their schema without touching the

script. See <lint_and_audit> below for the iteration loop;

references/lint_checks.md has the full check matrix. The

auto_shaper_wiki agent wraps lint.py with a complete

assess → fix → verify loop in an isolated context. Spawn it when the user

asks for a broad audit, lint, fix, health-check, clean-up, or auto-repair

pass over the wiki.

</lint>

<fallback_without_scripts>

Without access to the scripts, perform discovery inline with the same rule: a

directory is a wiki when its basename contains "wiki" (case-insensitive) and

at least two of SCHEMA.md / index.md / log.md are present and it carries

no .no_wiki. If CWD is itself a wiki, use it. Otherwise walk up from CWD

toward $HOME: at each level treat <level>/.no_wiki as "skip", the first

child directory recognised as a wiki (lexical order) as a hit (and stop

walking), anything else as a creation candidate. Auto-resolve only when the

closest non-opted-out level holds a recognised wiki or every level up through

$HOME is opted out (use $HOME/wiki). Otherwise follow the explicit workflow

in <resolving_the_wiki_location>. Never silently route to an upstream wiki.

</fallback_without_scripts>

</tools>

<resolving_the_wiki_location>

This is the discovery flow. Every wiki operation (ingest, query,

update, archive, lint, audit, init) runs it before touching any file in a

wiki. The rule applies regardless of how the user phrased their request

("update the wiki", "add a page", "lint", etc.); the operation does not

begin until this resolves.

<the_hard_rule>

The hard rule. When discover_wiki.sh exits 2, you MUST present the

candidates and ask the user, **unless <adopt_when_user_named_the_path>

applies. Do not** silently adopt an upstream EXISTING: candidate

when CWD is an unresolved AVAILABLE: level, because the user may want a local

wiki for this directory, and silently writing to a wiki one or more

levels above the current project is a confidentiality and scoping

mistake. Exit 2 is the script telling you the location is ambiguous,

not a recommendation.

</the_hard_rule>

<adopt_when_user_named_the_path>

Carve-out to <the_hard_rule>. When the user's current request

explicitly names one of the AVAILABLE: or EXISTING: paths returned

by exit 2, set $WIKI from that candidate the way <proceed_with_operation>

does, without prompting, and report the adoption in one line so the

auto-choice is observable to the user, e.g.

Using $WIKI=/path/to/wiki (per your message).

The user can correct in the next turn if the match was wrong. Silence

is the failure mode this surface report exists to prevent. Two bounds

keep this safe:

that is not on the exit-2 candidate list, fall back to the full

<the_flow>. Never invent or extrapolate a wiki location.

request.** If the user named none, or named more than one, present

all candidates and ask.

</adopt_when_user_named_the_path>

<the_flow>

<run_discovery>

Run "$WIKI_SKILL/scripts/discover_wiki.sh".

Adopt it as $WIKI. If the path does not yet exist on disk, init it

with "$WIKI_SKILL/scripts/init_wiki.sh" "$WIKI" before proceeding.

EXISTING:<path> per line, in walk order from CWD upward). Continue

with <present_candidates>. Do not pick a candidate yourself.

</run_discovery>

<present_candidates>

Present every candidate to the user, in walk order, with the kind

spelled out so the choice is unambiguous:

at <level>/wiki via init_wiki.sh, as <proceed_with_operation>

sets $WIKI.

that wiki for the current operation.

Ask: "Which path should host the wiki for this operation?" Wait

for the user's answer.

</present_candidates>

<offer_no_wiki_markers>

Offer .no_wiki markers for the unchosen AVAILABLE candidates

between CWD (inclusive) and the chosen path (exclusive), the levels

the user walked over to reach their pick. Ask once, covering all of

them in a single yes/no:

"Drop a .no_wiki opt-out marker in <path-1>, <path-2>, …

so future walks from those subtrees skip straight past?"

On yes, create an empty .no_wiki file at each path. On no, leave

them untouched. Levels above the chosen path are not offered markers, because

the walk-up will short-circuit at the chosen wiki anyway.

</offer_no_wiki_markers>

<proceed_with_operation>

Set $WIKI from the chosen path, then scaffold and proceed. The chosen

path is the candidate discovery printed. An EXISTING: pick is the wiki, so

$WIKI is that path. An AVAILABLE: pick is the level that will hold the

new wiki, so $WIKI is <chosen path>/wiki, and

"$WIKI_SKILL/scripts/init_wiki.sh" "$WIKI" scaffolds it. Proceed with the

operation against $WIKI.

</proceed_with_operation>

</the_flow>

<common_case>

Common case worth calling out. CWD has no wiki and no .no_wiki,

but a parent directory does. The script reports

AVAILABLE:<CWD> followed by EXISTING:<parent>/wiki and exits 2. The

default response is to ask. Silently routing to the upstream is the

mistake <the_hard_rule> exists to prevent. The user may want to

(a) create a wiki right here, (b) drop a .no_wiki here and let the

upstream wiki own this subtree from now on, or (c) adopt the upstream

wiki for this session without a marker. They pick. The single

exception is <adopt_when_user_named_the_path>: when the user's

current request already named one of the candidates, adopt it and

report the adoption in one line instead of asking.

</common_case>

</resolving_the_wiki_location>

<resuming_an_existing_wiki>

When the user has an existing wiki, **always orient yourself before doing

anything**:

  1. Read SCHEMA.md to understand the domain, conventions, and tag taxonomy.
  2. Read index.md to learn what pages exist and their summaries.
  3. Scan recent log.md: read the last 20 to 30 entries by entry

boundary rather than by a fixed line count. List the entry anchors, then

read a bounded slice from the earliest offset you need:

```bash

grep -n '^## \[' "$WIKI/log.md" | tail -30

```

Read from that earliest anchor's line number with an explicit limit,

which keeps the slice inside the 25000-token cap even on a large log (see

<too_large_to_read_in_one_shot>). The log rotates at 500 entries, so it

stays bounded; a full read still wastes context.

Only after orientation should you ingest, query, or lint. Skipping this causes

duplicate pages, missed cross-references, schema-contradiction, and repeated

work.

For large wikis (100+ pages), also run a quick recursive search (rg /

grep -r) for the topic at hand before creating anything new.

</resuming_an_existing_wiki>

<initializing_a_new_wiki>

When the user asks to create or start a wiki, <resolving_the_wiki_location>

already covers steps 1 to 3 (run discovery, present candidates, offer

.no_wiki markers in unchosen levels). The init-specific steps follow once

$WIKI is chosen:

  1. Run "$WIKI_SKILL/scripts/init_wiki.sh" "$WIKI" against $WIKI as

<proceed_with_operation> sets it, to scaffold SCHEMA.md, index.md,

log.md, and the directory tree.

  1. Customize the schema. Ask the user what domain the wiki covers.

Be specific. The freshly initialized SCHEMA.md has placeholder text

in the Domain and Tag Taxonomy sections. Read

references/template_schema.md for what each section should contain.

Define 10 to 20 starting tags before any pages are written, since the

linter flags off-taxonomy tags.

  1. Confirm the wiki is ready and suggest first sources to ingest.

</initializing_a_new_wiki>

<core_operations>

<ingest>

When the user provides a source (URL, file, paste), integrate it into the wiki:

<capture_raw_source>

Capture the raw source:

where one applies). Use source_url: for an externally-published source and

a relative source_path: for a source the repo tracks (it may sit outside the

wiki dir but must stay inside the repo), never an absolute, ~-prefixed, or

repo-escaping path. A raw-sidecar source_path: resolves from the wiki root;

open it with Read as $WIKI/<source_path-value>. A local file outside the

repo takes no path:

excerpt it into the body and note its locality in prose. The

### raw/ Frontmatter contract in references/template_schema.md is the

canonical statement of these field meanings and of how a mislabeled or legacy

sidecar reconciles onto them. Follow it rather than restating it here.

Compute and write the hash with

python3 "$WIKI_SKILL/scripts/compute_sha256.py" raw/<kind>/<slug>.md.

Never invent the value by hand.

record of what the source said last time, so establish drift while that

record still stands. Write the freshly fetched or converted body to a

session-local temporary file outside the wiki tree, under a verbatim copy of

the existing sidecar's frontmatter through its closing --- with the

recorded sha256 carried over untouched, reproducing the blank line the

sidecar keeps beneath that closing --- because the hash covers everything

after it. Run

python3 "$WIKI_SKILL/scripts/compute_sha256.py" --check <temp-sidecar> on

that temporary file (report-only mode, it writes nothing) while the

sidecar on disk stays as it is. ok and exit 0 mean the source is

unchanged: skip, leaving the sidecar untouched, with no body rewrite, no

hash refresh, and no log.md entry. update and exit 1 mean drift: rewrite

the sidecar body to what the source now says, refresh the recorded hash with

the write-mode command above, and report the drift both to the user and in

the ingest's log.md entry. Running the write mode over the sidecar itself

first erases the mismatch that decides this branch.

link from one raw file to another is ingester synthesis, not source

content (originals cite by URL, not by ingester-picked slugs).

File the cross-reference on the wiki page that cites both sources

instead.

captured body quotes text that may carry markdown-sensitive characters

(HTML-like tags, backticks, headings), write it as a fenced text block,

never a blockquote: a blockquote breaks on inline HTML and trips

markdownlint MD033, while a fence declares the text as raw content that

is not rendered. Pick the smallest backtick fence count of three or more

that is longer than any backtick run already inside the content, so a

source carrying a four-backtick example takes a five-backtick fence.

</capture_raw_source>

<non_canonical_raw_artifact_ingestion>

Capture a non-canonical artifact before a page draws on it. A session

transcript, paste, meeting note, screenshot OCR, voice memo, or internal

scratch that informs a wiki page is raw material the wiki must be able to

re-read, so it enters the wiki before the page that uses it:

references/raw_taxonomy.md and the frontmatter contract in

### raw/ Frontmatter of references/template_schema.md: source_url:

for a published origin, a wiki-root-relative source_path: for an in-repo

source, neither field for an out-of-repo machine-local artifact, plus

ingested: and a body-only sha256: written by

python3 "$WIKI_SKILL/scripts/compute_sha256.py".

its wiki-root-relative path.

original artifact, as the fenced text block <capture_raw_source> defines.

routes through sources:, and per-claim attribution is an inline link to

the same sidecar beside the claim.

This channel and ## Derived from divide the work. An artifact whose content

informs a page and that the wiki must re-read, whether ephemeral or

machine-local, takes the raw/ channel. Durable external material the wiki

points at but does not own or classify, such as a doctrine file in another

repo, a codebase, or a notebook, stays where it lives and is recorded as a

## Derived from pointer, never captured into raw/ and never listed in

sources:. The wiki_import skill's <capture_raw_mid_conversation> block

carries the capture protocol for an artifact that arrives mid-conversation.

</non_canonical_raw_artifact_ingestion>

<discuss_takeaways>

Discuss takeaways with the user: what's interesting, what matters

for the domain. (Skip in automated/cron contexts.)

</discuss_takeaways>

<check_what_already_exists>

Check what already exists. Search index.md and run a recursive

search to find existing pages for mentioned entities/concepts. The

difference between a growing wiki and a pile of duplicates.

</check_what_already_exists>

<write_or_update_pages>

Write or update wiki pages:

1. Check the dates; newer sources generally supersede older ones.

2. If genuinely contradictory, record both positions with their dates and sources on the page.

3. Mark the contradiction in frontmatter: contradictions: [other-page-slug] and contested: true.

4. Rely on lint to surface contested pages for user review; leave the resolution to the human.

</write_or_update_pages>

<update_navigation>

Update navigation:

Update "Total pages" + "Last updated".

files actually created or updated in this ingest. Skip files that were

inspected, considered, or deliberately left unchanged, and do not

narrate decisions about what not to do. Aim for roughly 20 lines per

entry. If it grows past that, the entry is logging non-changes or

prose that belongs on a wiki page instead.

</update_navigation>

<run_linter_and_iterate>

Run the linter and iterate. python3 "$WIKI_SKILL/scripts/lint.py".

Fix every blocking finding before declaring complete. This is the narrow

post-ingest check; for broad audits across the whole wiki, spawn the

auto_shaper_wiki agent instead. See <lint_and_audit> below.

</run_linter_and_iterate>

<report_what_changed>

Report what changed to the user: list only files actually created or

updated, matching what the log entry contains.

</report_what_changed>

<bulk_ingest>

Bulk ingest (multiple sources at once): batch the work. Read all sources

first, identify all entities/concepts in one pass, check existing pages once

(not N times), write in one pass, update index.md once, single batch log

entry. Bulk ingests are the most likely operation to introduce structural

issues, so always lint to clean.

</bulk_ingest>

</ingest>

<capture_procedure>

When the user asks to record a workflow rule, convention, or runbook, or you

notice an operational pattern worth keeping, file it as a procedure page.

The page holds the evergreen rule; the worked example that prompted it

lives elsewhere. The default failure mode here is over-indexing on the current

example: a procedure page should still read as a rule six months from now on a

different task, with none of today's specifics in it.

<protocol>

Run every step in order:

<name_the_rule>

Name the rule. State the policy in 1 to 3 sentences using the form

"When [trigger], do [action], because [reason]." Keep the trigger and

action operator-neutral; "after every ingest that touches 5+ entities" is a

trigger, "the user just asked X" is not. Confirm the page reads as steps

for an operator to follow. Pages that read as facts about how a

mechanism works belong in concepts/, even when worded as "rules".

</name_the_rule>

<strip_the_instance>

Strip the instance. Replace every proper noun, file path, person's

name, date, error message, command output, and task-specific value with a

category placeholder, or delete it. Read the page back. If it still reads

as a rule, the rule is the carrier; if the page collapses without the

stripped specifics, the example was the carrier and the rule still needs

to be written.

</strip_the_instance>

<hoist_non_rule_content>

Hoist non-rule content to its proper home:

page.

experience earns a page.

</hoist_non_rule_content>

<bound_the_page>

Bound the page. Keep atomic procedure pages 30 to 80 lines. Hub pages

that chain atomics stay 30 to 60 lines and link out rather than restating

the underlying rules. Past the bound, hoist worked content per

<hoist_non_rule_content> or split into two atomic pages.

</bound_the_page>

</protocol>

<generality_tests>

A procedure page that survives all three tests is a keeper:

X. Read the page back. The rule still reads as a rule.

a different task in the same domain, recognizes this trigger and applies

this action.

circumstances belong on the source sidecar where they happened, not in

procedures/.

</generality_tests>

<update_navigation_for_procedure>

Update navigation: add the new procedure page to index.md under the

procedures section, alphabetically. Update "Total pages" + "Last updated".

</update_navigation_for_procedure>

<reference>

Reference: references/template_schema.md carries the page anatomy

(sections, atomic vs. hub split, hoist destinations).

</reference>

</capture_procedure>

<query>

When the user asks a question about the wiki's domain:

  1. Read index.md to identify relevant pages.
  2. For wikis with 100+ pages, also run a recursive search across all

.md files for key terms, because the index alone may miss relevant content.

  1. Read the relevant pages.
  2. Synthesize an answer with citations:

Based on [page-a](concepts/page-a.md) and [page-b](entities/page-b.md)…

  1. File the answer back on the three-page-or-novel-reasoning trigger.

Filing is the default action for an answer that draws on three or more

wiki pages, or that carries cross-page reasoning present on no single

page. Those are the answers painful to re-derive. An answer restating one

or two pages is a direct lookup, so it stays in chat. Pick the type by

entry point: comparisons/ for X-vs-Y, summaries/ for topic-organized

digests, queries/ for question-organized answers (see <page_types>).

Two provisions keep the trigger deterministic:

user has not yet reacted to gets filed on the same trigger, and its

page carries confidence: medium, a field every page type takes.

Write medium for a first synthesis however many pages it draws on:

what stays pending is the user's validation, while the high that the

**Confidence** bullet in <write_or_update_pages> reserves for

multi-source support speaks to the evidence behind the claims, so the

two signals answer different questions. A page filed as query

states that same pending status in its "Confidence and caveats"

section. A later user correction is an ordinary page update on the

<write_or_update_pages> path.

Name that reason in the one-line decision report below.

  1. Append a query log entry when the query changed files. A query that

filed a page or updated existing pages appends one entry listing exactly

those files. A query that answered from what was already there changed

nothing, so it appends nothing and the in-chat answer is its only trace

(see <appending_to_log>).

  1. Report the filing decision in one line. Close every query answer with

one line covering whichever branch happened: filed → name the created

page's path; skipped → give the reason in the trigger's own terms,

naming the page count or the absent cross-page reasoning. This line

stands in place of asking permission before filing: decide on the

trigger, report the call, and let the user correct it in the next turn,

the same surface-the-auto-choice shape

<adopt_when_user_named_the_path> uses.

</query>

<archive>

When content is fully superseded or the domain scope changes:

  1. Create _archive/ if it doesn't exist; move the page there preserving its

path (e.g., _archive/entities/old-page.md).

  1. Remove from index.md.
  2. Update inbound links: replace with plain text + "(archived)".
  3. Log the archive action.
  4. Run python3 "$WIKI_SKILL/scripts/lint.py": a page link left pointing at

the moved file surfaces as a blocking broken-link, and an index.md

entry you left behind surfaces as an index warn (the linter parses index

link targets and flags dangling ones), so both the inbound-link and

index-removal steps are backstopped.

</archive>

<lint_and_audit>

Two paths, picked by scope.

<broad_audits>

Broad audits: spawn the auto_shaper_wiki agent. When the user asks

to lint, audit, fix, health-check, clean up, or auto-repair the wiki, or

the wiki has accumulated drift across many pages, delegate to the

auto_shaper_wiki agent. The agent runs a complete

assess → fix → verify loop in an isolated context: runs lint.py,

audits the prose for issues the linter cannot see (topic mixing,

type/anatomy mismatch, procedure-page instance leakage, content violations

of the page-type anatomy), fixes every blocking and warn finding, splits

or relocates pages where the schema demands it, re-lints until the wiki is

clean, appends the audit entry to log.md, and reports back a per-file

change list. Keep that work in the agent rather than running the iteration

loop inline, because the fix loop on a real wiki touches dozens of files and

displaces conversation context.

</broad_audits>

<narrow_inline_checks>

Narrow inline checks: run "$WIKI_SKILL/scripts/lint.py" directly.

After a single ingest, a single archive, a schema edit, or a small batch

update, run the linter in-flow and fix what it surfaces:

python3 "$WIKI_SKILL/scripts/lint.py"              # auto-discover ./wiki (or ~/wiki when ./.no_wiki present)
python3 "$WIKI_SKILL/scripts/lint.py" /custom/path # explicit override
python3 "$WIKI_SKILL/scripts/lint.py" --quiet      # blocking + warn only

Findings come in three buckets:

index.md, missing or unparseable SCHEMA.md (no extractable type enum),

a log.md over 1000 entries. Exits 1; must fix.

invalid enum/date values, pages missing from the index, a log.md over 500

entries (rotate it to log-YYYY.md), a non-ASCII page or raw/ sidecar

filename (filename, whose message names the ASCII-folded slug to rename

to), and locked-slot

boilerplate mismatches that delete or replace canonical content (the

log.md preamble under the classify-as-extension contract). Insert-only

locked-slot additions are acknowledged-channel extensions, not live warns.

bold labels (heading-label: an H2-or-deeper heading or bold-label

structural text past 60 characters, and a parenthesised ISO-date suffix on a

heading at any level or a bold label; H1 is exempt from the length rule),

low-confidence

single-source pages, unused taxonomy tags, duplicate

log.md entry headings (log-heading), log.md entry bullets whose

subject is a path outside the wiki (log-scope), index.md's

Total pages: header disagreeing with the page walk or missing entirely

(index-count), and synthesis-page

citation inconsistency (citation): declared-but-never-cited (a sources:

entry with no inline link), cited-but-undeclared (an inline link under raw/

or a declared source root absent from sources:), and zero-inline-links (a synthesis page with no

local .md inline links). The two log-entry checks

are surfaced for review because repairing an entry already written is an

operator-requested move rather than a routine sweep. The citation check

verifies presence and channel consistency, not grounding: cite where the

claim is grounded rather than adding a citation to clear the check.

Full check matrix: references/lint_checks.md.

</narrow_inline_checks>

<inline_iteration_loop>

Inline iteration loop. When the lint scope is narrow (one ingest, one

archive), run, fix the highest-severity findings, re-run. Repeat until the

script exits 0. A contested: true page keeps its warn by design. That

dispute signal is for a human to resolve, so it stays in the report. Append

the outcome to log.md:

## [YYYY-MM-DD HH:MM] lint | N blocking, N warn, N info

Four non-overlapping structural routes settle a finding without editing the

script, and each covers only its own finding class:

info-level findings only (grammar that section documents). The next run

drops the finding from the live report and the live counts and lists it

under ACKNOWLEDGED.

boilerplate check classifies it and reports it on the acknowledged

channel).

intentional locked-slot remove-or-rewrite divergence.

in-repo source root that widens sources: beyond raw/; a valid

declaration is reported on the acknowledged channel with a (declared)

marker.

These are not alternatives for one another: the acceptance store never

suppresses a warn, a declaration never accepts an info finding, and

Page-check exclusions: only drops whole trees from the page walk. Write a

decision in SCHEMA.md when that route owns it, never as rationale prose in

the page body, and never as a fresh log paragraph each run. Leave the script

alone: it surfaces, it doesn't enforce.

</inline_iteration_loop>

</lint_and_audit>

</core_operations>

<operational_discipline>

<searching>

rg "transformer" "$WIKI" -g "*.md"            # by content
fd -e md . "$WIKI"                            # by filename
rg "tags:.*alignment" "$WIKI" -g "*.md"       # by tag

For recent log entries, use the entry-anchor recipe in

<resuming_an_existing_wiki> rather than a fixed line count.

</searching>

<appending_to_log>

An entry records a change. Append to log.md when the operation created

or updated wiki files, and write no entry at all when it changed none: a

question answered from existing pages, an inspection that found nothing to

fix, a proposal the user declined. Lint and audit runs are the one exception:

each records its outcome as a process record even when it changed nothing

(<inline_iteration_loop> below and the auto_shaper_wiki audit entry), so

the next run has a baseline to read.

An entry is about the wiki, and only the wiki. The subject of every bullet

is a file under the wiki and what changed on it. A change elsewhere in the

repository that holds the wiki (its source tree, tooling, tests, or version

metadata) belongs to that change's own commit message, and a finding worth

keeping goes onto the wiki page that owns it, after which the bullet names that

page instead of restating what it says. Citing an outside path mid-bullet as

the source a claim came from stays legitimate provenance; what stays out is

that path standing as what the bullet is about. Two failures this prevents: an

entry that reads as a commit message with one wiki bullet attached, and an

entry used as a parking lot for findings no page carries. log.md's own

preamble carries this rule at the point of use as its Scope: group, and the

linter surfaces a violation as an info log-scope finding.

Every new heading carries a timestamp. Write

## [YYYY-MM-DD HH:MM] action | subject in local 24-hour time. The time

component is what keeps two same-day entries with the same action and subject

from colliding, which markdownlint MD024 reports as a duplicate heading. A

legacy date-only heading stays valid exactly as written and is never

rewritten to add a time it never recorded.

*"Append-only" means newest at the bottom* of the file, and it binds the

substance.** Never reword, reorder, or delete what a past entry records. An

entry may still be edited to repair a structural or lint break it introduced,

such as a heading that collides with an earlier one or malformed markdown,

provided the repair keeps what the entry records and where it sits. Repair the

breakage; leave the substance alone. This is the one permission to touch an

entry already written.

The Edit tool's old_string matching makes it easy to anchor on a header and

insert before it, producing inverted order. Avoid that:

## [YYYY-MM-DD HH:MM] header. New content (blank line + new header + body)

goes after the anchor.

several entries (ingest → sidecar update → cite), write them earliest-first

within the cluster, same direction as the whole-file rule. Resist

reverse-chronological "outcome first" narrative ordering.

```bash

grep -n '^## \[' "$WIKI/log.md" | tail -5

```

The new entry's line number must be the largest. If not, fix before

continuing.

</appending_to_log>

<record_only_full_reads>

Both records move only over pages read in full. Two records claim what an

audit checked: the Audit baseline: an audit writes to log.md, and a page's

checked: date. Each moves forward only over the pages the same pass read in

full. A page is read in full only when the pass read every line of it, in one

read or in several reads in chunks that together cover the whole file; the

<too_large_to_read_in_one_shot> locate-then-Read path reads a range, not

the page. A claim on the page counts as checked only when the pass read the

source that claim cites, as the page's sources: frontmatter lists it and its

inline claim links cite it, so those source reads are the record. A source

counts as checkable when it lies inside the wiki or under a `Declared source

root:` the wiki declares, because the Provenance bullet in

<write_or_update_pages> resolves a sources: value from the wiki root and

lets a declared-root value point at a sibling of the wiki in the same

repository; a claim whose source lies outside both locations, or that the pass

read no source for, stays unchecked. A search hit, a context excerpt, and a

partial line range read neither the page nor its claims. The stamp refreshes a

checked date the page already carries and adds the field to no page, keeping

checked the optional signal references/template_schema.md defines and

matching the no-add rule in <fix_frontmatter_missing_or_malformed>.

</record_only_full_reads>

<file_handling_discipline>

Four rules keep tool use stable on long wiki sessions. Each addresses a

failure mode observed in real session traces.

<read_to_stage_edit>

**When the active Edit tool enforces a read-before-edit precondition, use

Read to locate the span you intend to change.** Read both shows the content

and stages the file for Edit; reserve Bash grep/cat/tail for counting,

log-offset or entry-anchor retrieval, the <too_large_to_read_in_one_shot>

locate-then-Read path, and <appending_to_log> post-edit verification,

because Bash output alone does not satisfy Edit's precondition.

</read_to_stage_edit>

<re_read_after_mutation>

**Re-Read each file you plan to Edit or Write after any operation that may

have modified wiki files.** Mutations that invalidate the harness's

"file-has-been-read" state include git mv, mv, sed -i, the linter when

run in auto-fix mode, helper scripts under skills/wiki/scripts/

(compute_sha256.py, init_wiki.sh, merge_log_preamble.py, lint.py

with side effects), a

subagent that performed edits during this session, and any external command

that touches the working tree. A stale Read causes the next Edit or

Write to fail with `<tool_use_error>File has not been read yet. Read it

first before writing to it.</tool_use_error>` and burns 3 to 5 turns per

occurrence on retries.

The pattern that triggers this most often: rename a page with git mv, then

update inbound links across other pages. The inbound-link Edits fail on

stale Reads. Re-Read each file you are about to update after the git mv,

before the first Edit.

</re_read_after_mutation>

<too_large_to_read_in_one_shot>

**When Read fails with `File content (N tokens) exceeds maximum allowed

tokens (25000)`, do not retry the same call.** The file is too large for a

single read and the same call will fail the same way. Switch strategy

instead:

limit to walk it in chunks.

Read only that range.

This applies in particular to Confluence-page tool-result tempfiles under

.../tool-results/mcp-claude_ai_Atlassian-getConfluencePage-*.txt and to

large raw sources (long transcripts, dense PDFs converted to markdown). The

failure mode to avoid is the same-call retry loop the model defaults to 3 to 5

times on this error.

</too_large_to_read_in_one_shot>

<list_before_manipulating_unfamiliar_paths>

**Before manipulating a wiki path you have not recently confirmed (rename,

move, Read of a new location, Write of a new file), list the parent

directory once.** A single ls <parent> or

fd -e md . <parent> -d 1 is enough. This catches stale path

assumptions (a slug the model remembers from earlier that was already

renamed, a directory it expects to exist that does not, a raw/<kind>/

bucket that was retired) before they turn into No such file or directory,

fatal: bad source, or a Write that lands in the wrong place.

</list_before_manipulating_unfamiliar_paths>

</file_handling_discipline>

</operational_discipline>

<pitfalls>

Quick-scan reminders. See the named section for full guidance.

<resolve_before_writing>

Resolve before writing. discover_wiki.sh exit 2 means ambiguous, not "use the upstream". Always present candidates and ask the user, even when an EXISTING: parent wiki shows up in the list. Silent upstream adoption is a confidentiality and scoping mistake. (see <resolving_the_wiki_location>)

</resolve_before_writing>

<orient_first>

Orient first. Read SCHEMA + index + recent log before any operation. (see <resuming_an_existing_wiki>)

</orient_first>

<raw_is_read_only>

raw/ is read-only. Corrections live in wiki pages, not in the source.

</raw_is_read_only>

<cross_references_are_layer_2>

Cross-references are layer 2, not raw. Synthesis links between sources live on the wiki page that cites both, never inside a raw body. (see <capture_raw_source> in <ingest>)

</cross_references_are_layer_2>

<update_navigation_reminder>

Update navigation. index.md and log.md lag → wiki degrades. (see <update_navigation> in <ingest>)

</update_navigation_reminder>

<log_only_what_changed>

Log only what changed. An operation that created or updated no wiki file writes no entry at all, and an entry that is written lists the wiki files actually created or updated; never narrate inspected-but-unchanged files or "did not edit" decisions. Every bullet's subject is a file under the wiki: a change elsewhere in the repository goes in that change's own commit message, and a finding worth keeping goes onto the page that owns it so the bullet names that page. Lint and audit outcome entries are the sanctioned exception. (see the Scope: group in log.md's preamble for the point-of-use copy of the subject rule, <appending_to_log> for when an entry is written, <update_navigation> in <ingest> for what it lists)

</log_only_what_changed>

<page_thresholds>

Page thresholds. Passing mentions don't earn a page. (template_schema.md)

</page_thresholds>

<cross_link_or_vanish>

Cross-link or vanish. Every page links to ≥2 others.

</cross_link_or_vanish>

<frontmatter_is_required>

Frontmatter is required: enables search, filtering, staleness detection.

</frontmatter_is_required>

<tags_from_taxonomy_only>

Tags from taxonomy only. Add new tags to SCHEMA first.

</tags_from_taxonomy_only>

<pages_stay_scannable>

Pages stay scannable. Split a fixed-growth page past ~200 lines and a growing page past ~500 lines, where the action is to split into sub-topics with cross-links or graduate entries to dedicated pages; detailed treatments go to dedicated pages.

</pages_stay_scannable>

<generalize_procedure_pages>

Generalize procedure pages. Name the rule, strip the instance, hoist worked content to raw/ sidecars or concept pages. The page reads as a rule on a different task next month, or it isn't a procedure. (see <capture_procedure>)

</generalize_procedure_pages>

<procedure_or_concept>

Procedure or concept? File pages an operator reads as steps to follow under procedures/; file pages a reader reads as facts about how something works under concepts/. Wording the body as "rules govern X" does not turn a description into a procedure. (see <page_types> and <capture_procedure>)

</procedure_or_concept>

<confirm_scope>

Confirm scope. Ingests touching 10+ existing pages need user OK first.

</confirm_scope>

<rotate_log_at_500>

Rotate the log at 500 entries: rename log.md to log-YYYY.md, or to the first free log-YYYY-N.md when that name is taken, then start a fresh log.md from the canonical preamble in references/template_log.md and record the rotation as the new log's first entry. The new log carries no baseline, so the next audit reads every page in the wiki in full and records a fresh baseline only when it does, otherwise writing unavailable.

</rotate_log_at_500>

<contradictions_are_explicit>

Contradictions are explicit. Record both with dates, mark in frontmatter, flag for review.

</contradictions_are_explicit>

</pitfalls>

<output_contract>

Return to the user the report each entry below names. Each operation in

<core_operations> has one entry, and an ambiguous discovery has one. Where a

step already promises part of a report, the entry cites that step by its tag or

bold lead-in. The cited step stays the one statement of that promise.

<ingest_report>

<ingest>: return the files the ingest created or updated, in the form

that <report_what_changed> sets. After a re-ingest that finds drift, add the

drift report that the Re-ingest compares before it writes rule in

<capture_raw_source> calls for.

</ingest_report>

<capture_procedure_report>

<capture_procedure>: return the path of the procedure page created or

updated, and the index.md navigation updates applied under

<update_navigation_for_procedure>.

</capture_procedure_report>

<query_report>

<query>: return the answer that Synthesize an answer builds, with its

citations. Close it with the one-line filing decision that

Report the filing decision in one line defines. That line names the filed

page's path or the skip reason in the trigger's terms.

</query_report>

<archive_report>

<archive>: return the archived page's new path under _archive/, the

index.md removal and inbound-link rewrites made for it, and the outcome of

the post-archive lint run.

</archive_report>

<lint_and_audit_report>

<lint_and_audit>: return the report of the path that ran. For the narrow

inline path, return the final finding counts by severity, logged to log.md

as <inline_iteration_loop> directs. For the broad path that <broad_audits>

delegates, return the auto_shaper_wiki agent's per-file change list and the

audit-complete line that the agent's <final_line> sets.

</lint_and_audit_report>

<ambiguous_discovery_report>

Ambiguous discovery: when discover_wiki.sh exits 2, return every

AVAILABLE: and EXISTING: candidate in walk order, as <present_candidates>

lays them out. Then return the path the user chose. When

<adopt_when_user_named_the_path> applies, return that block's one-line

adoption report, which names the adopted path.

</ambiguous_discovery_report>

</output_contract>

<family>

This wiki skill is the hub of a wiki_* family and carries the shared rules every front end inherits. Focused front ends each cover one slice and cite the hub's blocks by tag rather than restating them:

</family>

</wiki>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.