Citation Fixer logo

Citation Fixer

CommunityPopular
garrytan
citation-fixer

Audit and fix citation formatting across brain pages. Ensures every fact has an inline [Source: ...] citation matching the standard format. Extended in v0.25.1: scans for broken tweet/post references that lack actual URLs and resolves them via the host's X / Twitter API integration.

Overview

Publishergarrytan
Repositorygbrain
Skill namecitation-fixer
Stars
30.1K
Forks
4.5K
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by garrytan on GitHub. Read the source before you install it.

Installation

Install the Citation Fixer AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/garrytan/gbrain.git /tmp/gbrain
mkdir -p .claude/skills
cp -r /tmp/gbrain/plugin/skills/citation-fixer .claude/skills/citation-fixer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Citation Fixer in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Citation Fixer on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Citation Fixer is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Citation Fixer Skill

Convention: see conventions/quality.md for the canonical citation format every fix should match.

Output rule: all links MUST be deterministic (built from API data, not composed by LLM). See _output-rules.md.

Contract

This skill guarantees:

  • Every brain page is scanned for citation compliance.
  • Missing citations are flagged with specific location.
  • Malformed citations are fixed to match the standard format.
  • (v0.25.1) Tweet / post references without URLs are resolved via X API and patched with deterministic https://x.com/<handle>/status/<id> links.
  • Results reported with counts (scanned, fixed, remaining).

Phases

  1. Scan pages. List pages and read each one, checking for inline [Source: ...] citations.
  2. Identify issues:
    • Facts without any citation
    • Citations missing date
    • Citations missing source type
    • Citations with wrong format
    • (v0.25.1) Tweet references without x.com URLs
  3. Fix format issues. Rewrite malformed citations to match conventions/quality.md.
  4. (v0.25.1) Resolve tweet references via the X API integration.
  5. Report results. Count: pages scanned, citations found, issues fixed, tweets resolved, remaining gaps.

Tweet resolution pipeline (v0.25.1 extension)

For each broken tweet reference, follow this chain. The actual API call goes through whatever X integration the host has configured (typical shape: a recipe under recipes/x-api/ with handle / search-all endpoints).

Step 1: Identify broken references

Scan the page for patterns that indicate tweet references without URLs:

  • Contains words like tweeted, posted, said on X, RT, retweet, X post
  • Contains quoted text that looks like a tweet (short, punchy, often starts with a quote)
  • Has [Source: ... X/Twitter ...] without an x.com URL
  • References engagement metrics (likes, impressions) without a link

Step 2: Extract searchable content

From each broken reference, extract:

  • The handle (if mentioned: @<username>)
  • The quoted text (if available)
  • The approximate date (often present in surrounding timeline entries)

Step 3: Search for the actual tweet

Use the host's X API integration. Query patterns:

# Handle + quoted text:
from:<handle> "<exact quote fragment>"

# Quoted text only:
"<exact quote fragment>"

# Original of a retweet:
"<exact quote>" -is:retweet

Step 4: Verify and extract metadata

Once a candidate is found:

  • Confirm the text matches the quoted fragment.
  • Pull the tweet id, author handle, engagement metrics (likes / RTs / impressions).
  • Construct the URL: https://x.com/<handle>/status/<tweet_id>.

Step 5: Patch the brain page

Replace the broken citation with a proper one:

Before:

"<quote fragment>" [Source: <some hand-wavy attribution>]

After:

"<full verified quote>" — <N> likes, <N> RTs, <N> impressions
[Source: [X/<handle>, YYYY-MM-DD](https://x.com/<handle>/status/<tweet_id>)]

Batch mode

When sweeping many pages:

Find candidate pages

bash
# Pages mentioning tweets but with no x.com links
for f in $(find . -name "*.md" -not -path "./node_modules/*"); do
  refs=$(grep -ci "tweet\|posted\|x post\|RT\|retweet\|said on X" "$f")
  links=$(grep -c "x.com/.*/status/" "$f")
  if [ "$refs" -gt 2 ] && [ "$links" -eq 0 ]; then
    echo "$f"
  fi
done

Priority order

  1. Recently created / updated pages — fresh broken refs are easiest to resolve while context is fresh.
  2. High-traffic pages (frequent reads / writes from other skills).
  3. Everything else — bulk cleanup over time.

Rate limiting

  • X API: respect the host's tier limits; don't hammer.
  • Target ~50 pages per batch run.
  • 1-3 API calls per page (search + verify).
  • Batch-commit every 10-20 pages so a partial failure doesn't lose progress.

Output format

Citation Audit Report
=====================
Pages scanned:        N
Citations found:      N
Issues fixed:         N
Tweet links resolved: N
Remaining gaps:       N (pages with uncitable facts)

Anti-Patterns

  • ❌ Inventing citations for facts that have no source. Flag them.
  • ❌ Removing facts that lack citations (flag them; don't delete).
  • ❌ Fixing citations without reading the full page context.
  • ❌ Batch-fixing without checking quality on a sample first (see conventions/test-before-bulk.md).
  • ❌ Composing tweet URLs by guessing the tweet id. Always go through the X API; deterministic links only.

Integration

This skill can be called:

  • Manually — "fix citations on this page"
  • As a batch cron — weekly sweep of pages with broken refs
  • By other skillsenrich or media-ingest can call citation-fixer before commit to validate output

Metrics

If running as a recurring batch, track state in a small JSON file under ~/.gbrain/citation-fixer-state.json:

json
{
  "last_run": "2026-04-15T...",
  "pages_scanned": 0,
  "citations_fixed": 0,
  "tweet_links_resolved": 0,
  "citations_unresolvable": 0,
  "pages_remaining": 1424
}

Output Format

The skill's output shape is documented inline in the body sections above (see "Output", "Brain page format", or equivalent). The literal section header here exists for the conformance test (test/skills-conformance.test.ts).

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Citation Fixer AI skill do?

Audit and fix citation formatting across brain pages. Ensures every fact has an inline [Source: ...] citation matching the standard format. Extended in v0.25.1: scans for broken tweet/post references that lack actual URLs and resolves them via the host's X / Twitter API integration.

Why use Citation Fixer on TypingMind?

Because you install it once and use it with any model. Citation Fixer is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Citation Fixer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/garrytan/gbrain/tree/master/plugin/skills/citation-fixer. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Citation Fixer?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Citation Fixer?

As many as you like. As long as a model supports skills, you can use Citation Fixer with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Citation Fixer AI skill free?

Yes. It is published on GitHub by garrytan under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇