- Home
- Skills
- APIs & Backend
- Corpus-Guarded Query Spell Correction for Search and RAG
Corpus-Guarded Query Spell Correction for Search and RAG
Users type `safty plan` and `recovry` and your search returns nothing.
$29
Works with the AI Agents you already use
Corpus-Guarded Query Spell Correction for Search and RAG
Example session with this skill installed
node scripts/correct-query.mjs --corpus data/corpus-tokens.json --dictionary data/en_US.txt --protect Agensi "how to deploy an agnt"
- Read your context and instructions
- Compiled the corpus-guarded query spell
The query has been processed against the corpus and dictionary. One correction was identified and applied to the retrieval string while protecting the brand term.
Query Correction Report
| Field | Value |
|---|---|
| Original Query | how to deploy an agnt |
| Retrieval Query | how to deploy an agent |
| Status | Corrected |
Corrections Detail
| Original | Corrected | Start | End | Reason |
|---|---|---|---|---|
| agnt | agent | 18 | 22 | candidate_match |
Trace Inspection
{
"action": "corrected",
"original": "agnt",
"normalized": "agnt",
"reason": "exactly one corpus token at Damerau-Levenshtein distance 1",
"corrected": "agent",
"candidateCount": 1
}
Next steps
- Pass the
retrievalQueryto your vector database or search index. - Update the UI to display: "Showing results for
how to deploy an agent. Search instead for how to deploy an agnt."
3. Add any missed domain terms to the protectedTokens array to prevent future false positives.
Connects securely to your tools. The creator never sees your data.
About this skill
Users type safty plan and recovry and your search returns nothing. A general spell checker is the wrong fix: it turns safely into safety, kill into kiln, and your product name into a dictionary word. This corrector is conservative by construction.
Corrector (corrector.mjs): a token is changed only when it is absent from your corpus vocabulary, absent from a general dictionary, not one of your protected terms, and the corpus offers exactly one token at Damerau-Levenshtein distance one (one substitution, insertion, deletion or adjacent transposition) or a leader at least 3x the runner-up's corpus frequency. Short, numeric and punctuated tokens are never touched. correctQuery returns retrievalQuery for candidate generation plus the untouched originalQuery and every correction with offsets and a reason, so the interface can show "Showing results for ... search instead for ...". inspect explains each refusal. Dependency-free, synchronous, deterministic.
Corpus builder (build-corpus.mjs): tokenizes your documents (Markdown, text, HTML with tags stripped) with the same rule queries use, so corpus and query vocabularies match.
Dictionary fetcher (fetch-dictionary.mjs): downloads a permissively licensed American English word list at a pinned commit, verifies its SHA-256 and saves the license notice next to it; or copies a local list.
CLI (correct-query.mjs) and 14 tests covering normalization, edit-distance cases, every gate, dominance thresholds, protected terms, offsets, clean-query identity, configuration validation, and the corpus builder plus CLI end to end. reference/safety-contract.md explains the gates, the consumer's obligations and how to measure.
Node 18+, no packages. Network only in the fetcher, and only to fetch the pinned list.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Single-edit typos only. No CJK support. Linear scan performance limits vocabulary to a few hundred thousand tokens. Requires Node 18+.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 17 days ago
- Software
Node.js 18+