Ingest a new source into the wiki. Skips sources the log shows are already ingested and unchanged, reads the source, summarizes it, creates a wiki/sources/ page, updates affected topic and entity pages, flags contradictions, logs the activity, and commits the result to git. Trigger phrases: /brain-ingest, ingest [file or URL], add this source, read and file this, process this article/paper/note, ingest everything new, reingest [file], force ingest.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Brain Ingest?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/jessepinkman9900-brain-ingest)
---
name: brain-ingest
description: "Ingest a new source into the wiki. Skips sources the log shows are already ingested and unchanged, reads the source, summarizes it, creates a wiki/sources/ page, updates affected topic and entity pages, flags contradictions, logs the activity, and commits the result to git. Trigger phrases: /brain-ingest, ingest [file or URL], add this source, read and file this, process this article/paper/note, ingest everything new, reingest [file], force ingest."
argument-hint: "File path (e.g. raw-sources/articles/my-article.md), URL, 'everything new', or leave blank if source is pasted in chat. Add 'force' or say 'reingest' to ingest again even if unchanged."
---
# Brain Ingest
Runs the full ingest workflow defined in CLAUDE.md (Step 0 to Step 10). Do not skip steps.
## Brain Discovery
All commands target the **default brain** registered in `~/.claude-second-brain/config.toml`.
Resolve paths at call time via the `claude-second-brain` CLI — do not bake paths into this file:
```bash
BRAIN_PATH=$(npx -y claude-second-brain path) # absolute path to the default brain's directory
```
qmd commands go through the CLI proxy, which sets `INDEX_PATH` for you:
```bash
npx -y claude-second-brain qmd -- query -c wiki "<terms>"
```
Pass `--brain <name>` before the `--` to target a non-default brain.
## Inputs
- **File path** — a file in `raw-sources/articles/`, `raw-sources/pdfs/`, or `raw-sources/personal/`
- **URL** — fetch the page, save it as a markdown file in `raw-sources/articles/`, then ingest that file
- **Pasted text** — treat whatever the user has shared as the source
- **"Everything new"** — batch mode: every file under `raw-sources/` that the log has no matching entry for (see Batch mode below)
- **Override** — "force", "reingest", or "re-ingest" ingests the source again even if the log says it is unchanged
## Workflow
**Step 0 — Check the log (idempotency)**
`wiki/log.md` is the record of what has been ingested. Each ingest entry carries a `source:` line with the source's identity and a content hash (see Step 9). Before doing anything else:
- File in `raw-sources/`: take its path relative to the brain root and hash it:
```bash
SRC=raw-sources/articles/my-article.md
HASH=$( (shasum -a 256 "$BRAIN_PATH/$SRC" 2>/dev/null || sha256sum "$BRAIN_PATH/$SRC") | cut -c1-12 )
grep -n "^source: $SRC |" "$BRAIN_PATH/wiki/log.md" | tail -1
```
- URL: first look the URL up in the log, before fetching: `grep -n "| url: <url>$" "$BRAIN_PATH/wiki/log.md" | tail -1`. Any match means the page was already saved and ingested, so **skip** unless the user said force / reingest. If there is no match, go to Step 1, which saves the page into `raw-sources/` and gives it a path and hash like any other file.
- Pasted text: no check; always ingest.
Then decide, using the **latest** matching entry:
| Log says | Action |
|----------|--------|
| No entry | **New.** Run Steps 1–10. |
| Entry with the same hash (or any `url:` match, for a URL) | **Skip.** Tell the user it was already ingested on that date, link the source summary page from that entry, and stop. Mention they can say "reingest" to run it again. |
| Entry with a different hash | **Update.** The file changed since it was ingested. Run Steps 1–10 as an update (below). |
| Any entry, and the user said force / reingest | **Reingest.** Run Steps 1–10 as an update (below), even if the hash matches. |
**Update / reingest mode:** reuse the existing source summary page linked from the log entry (one summary per source; never create a second page). Revise it to reflect the current content, revise the pages it touched where the change matters, and log with the `reingest` action. If the update removes or reverses an earlier claim, fix it on the affected pages instead of leaving stale text.
Older log entries written before this check existed have no `source:` line. If a file has no `source:` match, also look for a `wiki/sources/` page that clearly covers the same file (same title, or it names the file). If one exists, ask the user whether to skip, or reingest into that page.
**Step 1 — Read the source**
- File: use the Read tool on the provided path
- URL: fetch the full content, then save it so the original survives even if the page changes or disappears:
- Write it to `$BRAIN_PATH/raw-sources/articles/[slug].md` (slug = kebab-case from the page title). If that file already exists, add the fetch date: `[slug]-YYYY-MM-DD.md`. Never overwrite an existing raw source.
- Content: the page text converted to markdown, as complete as the fetch allows, under this frontmatter:
```yaml
---
source_url: https://example.com/post
title: Page Title
author: Name (if known)
published: YYYY-MM-DD (if known)
fetched: YYYY-MM-DD
---
```
- From here on treat it like a file source: set `SRC` to its path, compute `HASH` as in Step 0, and keep the URL for the log.
- On a forced reingest of a URL, fetch again. If the content matches the latest saved copy, reuse that file; otherwise save a new dated copy as above.
- Pasted text: treat as the source directly
**Step 2 — Discuss with the user**
- Summarize the source in 3–5 bullets
- Ask: what aspects matter most? Anything to emphasize or skip?
- Let the user's response shape which topics get deep treatment before proceeding
**Step 3 — Create source summary page**
- File: `$BRAIN_PATH/wiki/sources/[slug].md` (slug = kebab-case from title)
- Sections: title, author/date, one-paragraph abstract, key claims (bulleted), notable quotes (max 3), synthesis note, links to wiki pages this source touches
- Frontmatter: `type: source-summary`, `tags`, `updated: YYYY-MM-DD`
**Step 4 — Update `wiki/index.md`**
- Add the new source to the Sources Ingested section: one-line description + `[[wiki/sources/slug]]` link
**Step 5 — Identify affected wiki pages**
- Run: `npx -y claude-second-brain qmd -- query -c wiki "<source topic and key claims>"`
- Also Glob `$BRAIN_PATH/wiki/*.md` and `$BRAIN_PATH/wiki/sources/*.md` to catch anything qmd missed
- List all pages to create or update before proceeding
**Step 6 — Update or create wiki pages**
- For each affected page: read it, integrate the new information, add `[[wiki/sources/slug]]` to `sources` frontmatter, update `updated` date
- Create new topic/entity pages for anything that doesn't have one yet
- Write synthesis, not transcription — your own words, with source attributions
- Cross-link aggressively: any topic or entity mentioned should use `[[wiki/page]]`
**Step 7 — Flag contradictions**
- If the source contradicts anything on an existing page, add a `> [!WARNING] Contradiction` callout
- State both positions and both sources explicitly
**Step 8 — Update `wiki/overview.md`**
- Only if the source shifts the high-level synthesis or introduces a significant new theme
- Otherwise skip this step
**Step 9 — Append to log**
- Append to `$BRAIN_PATH/wiki/log.md` (never overwrite). Use `ingest` for a new source and `reingest` for an update or forced run:
```
## [YYYY-MM-DD] ingest | Source Title
[[wiki/sources/slug]] | Pages touched: [[wiki/page1]], [[wiki/page2]], ...
source: raw-sources/articles/my-article.md | hash: 1a2b3c4d5e6f
```
- The `source:` line is what Step 0 reads. Keep it on its own line starting with `source: `, with the path relative to the brain root and the first 12 hex characters of its SHA-256.
- For a URL, the path is the saved copy and the line ends with the URL: `source: raw-sources/articles/my-post.md | hash: 1a2b3c4d5e6f | url: https://example.com/post`
- For pasted text: `source: pasted | hash: -`
**Step 10 — Commit to git**
- If the brain is a git repo, commit this ingest on its own so it can be reviewed or rolled back with `git revert`:
```bash
cd "$BRAIN_PATH"
git rev-parse --is-inside-work-tree >/dev/null 2>&1 && {
git add -- wiki "$SRC" # omit "$SRC" for pasted text
git commit -m "ingest: Source Title" -m "source: $SRC | hash: $HASH" -- wiki "$SRC"
}
```
- Use `reingest: Source Title` as the subject for an update or forced run.
- Commit only `wiki/` and the source file (including a page saved from a URL), so unrelated changes in the vault stay out of the commit. Committing a raw source does not modify it.
- Do not push. obsidian-git (or the user) pushes on its next sync. Push only if the user asks.
- If it is not a git repo, or there is nothing to commit, skip this step and say so.
## Batch mode — "ingest everything new"
1. List every file under `$BRAIN_PATH/raw-sources/` (skip `README.md`, dotfiles, and `.gitkeep`).
2. Run the Step 0 check on each and sort them into **new**, **changed**, and **already ingested**.
3. Show the user the new and changed lists (and a count of the skipped ones) and confirm before starting.
4. Ingest each file in turn with Steps 1–10, so each source gets its own log entry and its own commit. Step 2 may be combined into one discussion up front if the user prefers.
5. Suggest `/brain-refresh` once at the end rather than after each file.
## Hard Rules
- Never modify anything in `raw-sources/` — immutable raw inputs. The one write allowed there is saving a fetched URL as a new file (Step 1); never overwrite or edit an existing one
- Every wiki page must have frontmatter with at least `type` and `updated`
- One source summary page per source — never merge two sources into one
- Always check the log (Step 0) before ingesting; never re-ingest an unchanged source unless the user asks