agentleFS
fbsmna-coderfbsmna-coder/karpathy-pro-max/skills/anti-hallucination/SKILL.md

anti-hallucination

Skill0 starsChanged 8 months agoMITView on GitHub

Never invent APIs, file paths, line numbers, library functions, CLI flags, or framework features. Use whenever making a factual claim about code or external systems — verify before stating, cite the source.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When stating a verified claim:

    line 41

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Anti-Hallucination

LLMs invent plausible-sounding APIs that do not exist, library functions that were removed two versions ago, CLI flags that match the convention but were never implemented, and file paths from a different project. The hallucination feels like knowledge — it is fluent, specific, and confident — but it is wrong, and the user will discover it the moment they try to run the code.

The rule

Never state a factual claim about code or external systems without verifying it in this session.

Verification means: you read the file, ran the command, fetched the docs, or grep'd the codebase. Not: "I remember seeing this," "this looks like it should work," or "the docs probably say."

What counts as a factual claim

  • "There is a function X in module Y."
  • "This file is at path /foo/bar/baz.ts."
  • "Library version 2.5.0 added support for X."
  • "The CLI flag is --strict-mode."
  • "Line 47 of main.py calls process()."
  • "The endpoint accepts POST /api/v2/users."

Each of these can be wrong. Each must be backed by a verification step in the current session.

How to verify

Claim typeVerification
Function exists in this codebaseGrep for the function name
File exists at pathls or Read the path
Library has feature XFetch official docs (use context7, web fetch, or read installed package source)
Line number / locationRead the file with -n and confirm
CLI flag existsRun --help and read it
API endpoint existsRead the route definitions, or curl it

How to cite

When stating a verified claim:

  • File reference: [file.py:42](path/to/file.py#L42) — specific line.
  • Library claim: link to official docs or version-specific changelog.
  • CLI claim: quote the --help output.

When you have NOT verified

Say so explicitly. Phrasings:

  • "I have not verified this — the API typically takes X but check before relying on it."
  • "Based on my training data (which may be outdated), this was at path Y."
  • "This is a guess based on framework conventions, not a fact."

The user can act on a labeled guess. They cannot act safely on a confident hallucination.

When to fetch fresh docs

Use context7 (or equivalent doc-fetcher) BEFORE writing code that calls a library API, even one you know well. Library APIs change. Your training data is months or years stale. The cost of fetching is seconds; the cost of a hallucinated function call is a debugging session.

Especially fetch for:

  • Recently updated libraries (anything 1.0+ in the last 12 months).
  • Cloud SDKs (AWS, GCP, Stripe, Supabase — these change constantly).
  • AI/ML libraries (anthropic, openai, langchain — fast-moving).
  • Your own project's internal APIs — read the actual code, not a mental model of it.

Example

Bad:

Agent: "I'll use redis.async_get(key, timeout=5) to fetch with a timeout." Function does not exist. Real API is await redis.get(key) and timeouts are configured at the connection level.

Good:

Agent: fetches redis-py docs via context7 "The async API uses await redis.get(key). Timeouts are set on the connection (Redis(socket_timeout=5)), not per-call. Adjusting the implementation."

The cost of getting this wrong

A hallucinated API call doesn't fail with a clear "this doesn't exist" error in many contexts — it gets caught by a generic exception handler, logs a confusing message, and silently returns garbage. The user trusts the code, ships it, and finds out in production. Hallucinations are the single most damaging class of LLM coding bug because they look correct.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.