Corpus-Guarded Query Spell Correction for Search and RAG

    1

    Users type `safty plan` and `recovry` and your search returns nothing.

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    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

    FieldValue
    Original Queryhow to deploy an agnt
    Retrieval Queryhow to deploy an agent
    StatusCorrected

    Corrections Detail

    OriginalCorrectedStartEndReason
    agntagent1822candidate_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

    1. Pass the retrievalQuery to your vector database or search index.
    2. 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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+

    Permissions

    Network Access
    Read Files
    Write Files
    Listed17 days ago

    What's inside

    Frequently Asked Questions

    Traditional spell checkers often 'correct' technical jargon into common words; this skill uses your specific document vocabulary (corpus) and a protected term list to ensure domain-specific names and product IDs remain untouched.

    No, this is a local, dependency-free Node.js implementation that runs in sub-milliseconds without API calls, making it significantly faster, cheaper, and more predictable than using an LLM for query cleaning.

    The package includes the core correction logic, a dictionary management script, a corpus indexer for your local files, and a CLI tool for immediate testing.

    It is compatible with any Node.js environment (v18+) and can be integrated into any AI agent framework or RAG pipeline as a pre-processing step before embedding generation or database retrieval.

    While it is highly efficient for most search use cases, it is optimized for Latin-script vocabularies under a few hundred thousand tokens and currently focuses on single-edit Damerau-Levenshtein distance errors.

    Yes, the tool returns detailed metadata including character offsets and the specific 'gate' that triggered the change, allowing you to easily build 'Showing results for...' prompts in your UI.

    New in APIs & Backend