Skip to content
Back to skills

Wiki Ingest

ASecurity

Ingest a file into the local LLM wiki and update source/entity/concept pages.

  • 6 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added November 26, 2026
testingpythongobashgit

Works with

  • cli

Security analysis

A100/100

Scanned November 26, 2026

npx -y skills add jleechanorg/jleechan-skills --skill wiki-ingest --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Wiki Ingest?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Wiki Ingest
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jleechanorg-wiki-ingest/badge)](https://www.skillsdirectory.com/skills/jleechanorg-wiki-ingest)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: wiki-ingest
description: Ingest a file into the local LLM wiki and update source/entity/concept pages.
---

# /wiki-ingest — Ingest a file into the LLM Wiki

## Usage
```
/wiki-ingest <file_or_path> [--wiki <wiki_dir>]
```

Ingest a source document into the wiki. Creates a source page, extracts entities and concepts, updates the index.

`--wiki <wiki_dir>` overrides the configured wiki location (`.wiki-default`, then `~/.wiki-default`, then `$WIKI_ROOT/wiki`; with none set, stop with "WIKI_ROOT not configured"). The `raw/` directory is derived as the sibling of the wiki dir: `$(dirname <wiki_dir>)/raw`.

## Execution

### Phase 1: Resolve wiki path and source file
```bash
# Parse args: file is first positional; --wiki <path> overrides default
# Check for local wiki default (project-level override)
if [ -f ".wiki-default" ]; then
  WIKI=$(cat .wiki-default)
elif [ -f "$HOME/.wiki-default" ]; then
  WIKI=$(cat "$HOME/.wiki-default")
elif [ -n "${WIKI_ROOT:-}" ]; then
  WIKI="$WIKI_ROOT/wiki"
fi
FILE_ARG="<first positional arg>"
# --wiki flag always wins over .wiki-default
if args contain "--wiki <path>"; then
  WIKI="<path>"
fi
if [ -z "${WIKI:-}" ]; then
  echo "WIKI_ROOT not configured: your wiki checkout (contains wiki/ and raw/). Example: export WIKI_ROOT=\$HOME/llm_wiki (or pass --wiki <wiki_dir>)" >&2
  exit 1
fi

WIKI_ROOT=$(dirname "$WIKI")
RAW_DIR="$WIKI_ROOT/raw"
SOURCE="$RAW_DIR/$(basename "$FILE_ARG")"

# Determine slug from filename
SLUG=$(basename "$FILE_ARG" | sed 's/\.md$//' | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')

# Create the publish branch FIRST, before anything writes to the worktree. The `cp` below and
# the Phases 2-8 edits all happen on this branch; a branch cut after them would either abort
# on local changes or carry them across.
set -e
BRANCH="wiki-ingest/$SLUG"

# Refuse a dirty checkout. The precondition above covers concurrent ingests; this covers
# edits that were already sitting here, which would otherwise ride through the switch and be
# committed with this ingest's files.
[ -z "$(git -C "$WIKI_ROOT" status --porcelain)" ] \
  || { echo "$WIKI_ROOT has uncommitted changes; use a clean checkout for the ingest" >&2; exit 1; }

git -C "$WIKI_ROOT" fetch origin main

# WITH --exit-code, ls-remote returns 2 for "no matching ref" and a different code
# (128 here) for auth or transport failure. Without the flag a no-match returns 0, so
# the flag is required for this distinction. Only a genuine 2 means "safe to create".
set +e
git -C "$WIKI_ROOT" ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1
LS_RC=$?
set -e
case "$LS_RC" in
  0) echo "origin/$BRANCH already exists; pick a new slug" >&2; exit 1 ;;
  2) : ;;  # documented no-match: safe to create
  *) echo "cannot determine whether origin/$BRANCH exists (ls-remote rc=$LS_RC); aborting" >&2; exit 1 ;;
esac

git -C "$WIKI_ROOT" switch -c "$BRANCH" origin/main

# Only now copy the source into raw/, on the new branch.
mkdir -p "$RAW_DIR"
cp "$FILE_ARG" "$SOURCE" 2>/dev/null || cp "$(pwd)/$FILE_ARG" "$SOURCE"
```

### Phase 2: Read source document
Read the file fully.

### Phase 3: Read wiki context
Read `wiki/index.md` and `wiki/overview.md` for current wiki state.

### Phase 4: Create source page
Write `wiki/sources/<slug>.md` using Source Page Format:

```markdown
---
title: "<title>"
type: source
tags: []
date: YYYY-MM-DD
source_file: <relative path>
---

## Summary
2–4 sentence summary.

## Key Claims
- Claim 1
- Claim 2

## Key Quotes
> "Quote here" — context

## Connections
- [[EntityName]] — how they relate
- [[ConceptName]] — how it connects
```

### Phase 5: Update index
Add entry to `wiki/index.md` under Sources section.

### Phase 6: Oracle impact check
If the wiki has an owner/oracle synthesis page (`wiki/syntheses/*-oracle.md`), check whether new content affects it. If so, append to `wiki/log.md`.

### Phase 7: Entity & concept extraction
Create entity pages for key people, companies, projects.
Create concept pages for key ideas, frameworks, methods.

### Phase 8: Log
Append to `wiki/log.md`: `## [YYYY-MM-DD] ingest | <Title>`

### Phase 9: Commit and Push

The publish branch already exists and is checked out (Phase 1), so this phase only
commits, pushes and opens the PR. Never push `main`.

**Preconditions** — one is an operator responsibility, one is checked mechanically:

- **Operator:** this checkout is not being written by another ingest. `raw/` and
  `wiki/index.md`/`wiki/log.md` are shared paths, and `git add` takes a file's whole
  current contents, so two concurrent ingests cannot be separated once their edits are
  mixed. Nothing in the run can detect another writer. If the checkout is shared, use a
  separate clone.
- **Checked in Phase 1:** no pre-existing uncommitted edits are sitting in the checkout,
  and no branch already exists for this slug. Both are refused before the switch.

The dirty-checkout check is a snapshot at Phase 1, not a lock held for the run.

Stage exactly the paths this run wrote. `SOURCE` keeps the source file's extension while
`SLUG` strips it, so the raw copy is `$SOURCE`, not `raw/$SLUG`:

```bash
PATHS=("$SOURCE" "$WIKI_ROOT/wiki/sources/$SLUG.md" \
       "$WIKI_ROOT/wiki/index.md" "$WIKI_ROOT/wiki/log.md")
# add each entity/concept page this run wrote
```

Commit those paths explicitly — `git commit` with no paths commits the *entire* index,
including anything a previous run left staged:

```bash
set -e
git -C "$WIKI_ROOT" add -- "${PATHS[@]}"
git -C "$WIKI_ROOT" diff --cached --quiet -- "${PATHS[@]}" \
  && { echo "nothing staged for this ingest" >&2; exit 1; }
git -C "$WIKI_ROOT" commit -m "<cli>/<model>: docs(wiki): ingest $SLUG" -- "${PATHS[@]}"
```

Push, verify that exact commit landed, and only then open the PR. Verify before creating
the PR, and require nonempty values — `test "$A" = "$B"` is true when both are empty,
which is what a failed push plus a failed lookup produces. `gh` has no `-C` flag:

```bash
COMMIT="$(git -C "$WIKI_ROOT" rev-parse HEAD)"
git -C "$WIKI_ROOT" push origin "$BRANCH"
REMOTE="$(git -C "$WIKI_ROOT" ls-remote origin "refs/heads/$BRANCH" | awk '{print $1}')"
[ -n "$REMOTE" ] && [ "$REMOTE" = "$COMMIT" ] \
  || { echo "push did not land $COMMIT (remote='${REMOTE:-none}')" >&2; exit 1; }
# Open as a DRAFT unless the target repository documents an exception; draft-first is
# the shared default. Use --web or the repository PR template if one is required.
(cd "$WIKI_ROOT" && gh pr create --draft --base main --head "$BRANCH" --fill)
```

Note in the PR body when this run did not update the shared index or log. Leaving the
checkout on `$BRANCH` is fine; return to the previous branch only if the caller needs it.

## GitHub-Readable Output — TOC + Standard Markdown Links (default for ported-source branch)

When a ported-source page will be published to GitHub (gist, repo, or any non-Obsidian viewer), GitHub does **not** render `[[WikiLinks]]` as clickable — they show up as literal `[[brackets]]`. Default behavior for any ported-source ingest that touches a GitHub-rendered surface:

1. **Add a Table of Contents** at the top of the document, after the metadata block, with anchor links to every major heading. Format:
   ```
   ---

   ## Table of Contents

   1. [Setup & Cast](#setup--cast)
   2. [Beat 1 — Example Scene](#beat-1--example-scene)
   ...
   ```

2. **Convert all `[[WikiLinks]]` to standard `[label](url)` markdown links** pointing to the canonical GitHub raw URL for the target page. Slug → URL map should be built up front based on the page tree under `wiki/`. Example:
   ```python
   # Derive from the wiki checkout: git -C "$WIKI_ROOT" remote get-url origin (https form)
   wiki_url = "https://github.com/<owner>/<wiki-repo>/blob/main"
   wiki_link_map = {
       "ExampleEntity":   f"{wiki_url}/wiki/entities/example-entity.md",
       "ExampleConcept":  f"{wiki_url}/wiki/concepts/example-concept.md",
   }
   new_text = re.sub(r"\[\[([^\]]+)\]\]",
       lambda m: f"[{m.group(1).split('|')[-1]}]({wiki_link_map.get(m.group(1).split('|')[0], f'{wiki_url}/wiki/{m.group(1)}.md')})",
       src)
   ```

3. **Preserve `[[WikiLinks]]` in the Obsidian-side copies** (the `$WIKI_ROOT/wiki/sources/...` page) so they still work in Obsidian/Logseq — only the gist/published GitHub version converts them.

4. **Header metadata block** should include clickable links to the source transcript and the wiki source page when the document is going to a gist or remote repo.

This rule was added 2026-06-13 after a published playthrough gist had `[[WikiLinks]]` that didn't render on github.com. Apply by default to any future ported-source ingest.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.