Agent skill

Compromise NLP for JavaScript

by spencermountain in spencermountain/compromise

Guide for writing correct code with the compromise rule-based NLP library: tagging, match syntax, in-place transforms and common tasks like tense changes and redaction.

MITAuto-check passedAI & LLM Engineering

Install Compromise NLP for JavaScript

skills CLI
$ npx skills add spencermountain/compromise --skill compromise-nlp -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install spencermountain/compromise compromise-nlp --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/spencermountain/compromise.git skills-src && mkdir -p .claude/skills && cp -r skills-src/docs .claude/skills/compromise-nlp && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
compromise-nlp
GitHub stars
12k
Token cost
~1.8k tokens
SKILL.md length
569 words
Files
9
Skills in repo
2
Repo updated
First seen
Licence
MIT

At a glance

Guide for writing correct code with the compromise rule-based NLP library: tagging, match syntax, in-place transforms and common tasks like tense changes and redaction.

  • Works in 5 steps: Transforms mutate the document in place… → Only real tags work — an invalid #Tag… → Match-syntax is term-level, not regex → …
  • Writing or editing JavaScript that imports compromise or calls nlp()
  • SKILL.md covers The five rules that prevent…, Common tasks (verified patterns), Sharp edges to warn the user… and Debugging a wrong result, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

compromise is a rule-based English NLP library for JavaScript that needs no network, model or dependencies. You turn text into a document, the library tags each word's part of speech, and you find and transform parts of the text with a chained, jQuery-like API. The skill exists because its match syntax and tag set are easy to get wrong from memory, and it asks the agent to consult it before guessing whenever code imports compromise or calls `nlp()`.

It leads with rules that prevent most mistakes. Transform methods such as `.toPastTense()` and `.replace()` change the document in place, so the result is read from the original variable, with `.clone()` available to leave it untouched. Only real tags work: there are around 88 in a hierarchy, and an invented one such as `#Name` or `#Location` silently matches nothing. Match syntax works on whole terms rather than characters, with `/regex/` tokens for character-level patterns. Reference files cover the API, recipes, match syntax and tag definitions; the excerpt ends after the third rule.

When your agent uses it

  • Writing or editing JavaScript that imports compromise or calls nlp()
  • Extracting people, places, dates or numbers from English text with rules
  • Changing verb tense, pluralizing or normalizing text in JavaScript
  • Redacting or anonymizing names in a block of text

Example prompts

  • “Use compromise to pull all people and organizations out of this article text.”
  • “Write a function that converts every sentence in a string to past tense with compromise.”
  • “Anonymize the names in ./data/transcripts.txt using compromise.”
  • “Build a simple chatbot intent matcher with compromise match patterns.”

Requirements

  • The compromise npm package

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Transforms mutate the document in place — read the result from the original variable
  2. Only real tags work — an invalid #Tag matches nothing, silently
  3. Match-syntax is term-level, not regex
  4. Sentences are the ceiling — matches don't cross sentence boundaries
  5. compromise is the full build — import it unless size is critical

What it can do on your machine

Read from SKILL.md and the folder at commit 2e7a1b9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are javascript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Compromise NLP for JavaScript loads about 1.8k tokens when it runs. Until then it costs about 189 tokens; SKILL.md has 569 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~189
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from spencermountain/compromise at commit 2e7a1b9, republished under its MIT licence (© spencermountain). 569 words, ~1,795 tokens.

Download SKILL.mdSave it as .claude/skills/compromise-nlp/SKILL.md (or your agent's skills folder). This skill also uses 8 other files; get the full folder from GitHub.
name
compromise-nlp
description
Write correct code with the `compromise` JavaScript NLP library (the npm package `compromise`, imported as `nlp`). Use this whenever you are writing or editing JS/TS that imports compromise, calls `nlp(...)`, or chains methods like `.match()`, `.tag()`, `.people()`, `.verbs()`, `.nouns()`, `.numbers()`, `.normalize()`, or `.replace()` — and also whenever doing rule-based natural-language tasks in JavaScript (extracting entities/dates/numbers, matching text patterns, changing verb tense, pluralizing, redacting/anonymizing text, building a simple chatbot intent matcher) where compromise is or could be the tool. compromise's match-syntax and tagset are non-obvious and easy to get wrong from memory; consult this skill before guessing.

Using compromise

compromise is a rule-based English NLP library for JavaScript (no network, no model, no deps). You tokenize text into a document, it tags each word's part-of-speech, and you find and transform parts of the text with a jQuery-like chained API.

js
import nlp from 'compromise'

let doc = nlp('she sells seashells by the seashore.')
doc.verbs().toPastTense()        // transform
doc.text()                       // 'she sold seashells by the seashore.'

The five rules that prevent almost every mistake

These are the things that are easy to get wrong from memory. Internalize them before writing code.

1. Transforms mutate the document in place — read the result from the original variable

Every transform method (.toPastTense(), .replace(), .tag(), .normalize(), case/whitespace methods…) changes the underlying document. The View it returns is the selection it acted on, not the whole document. So calling .text() on the chain gives you only the selected fragment:

js
let doc = nlp('I walk to work')
doc.verbs().toPastTense()
doc.text()                                            // ✅ 'I walked to work'  (read from doc)

nlp('I walk to work').verbs().toPastTense().text()    // ❌ 'walked work'  (just the selection)

To transform a copy and leave the original untouched, call .clone() first:

js
let past = doc.clone().verbs().toPastTense().text()

Read-only methods (.match, .has, .if, .found, .text, .json, accessors) never mutate.

2. Only real tags work — an invalid #Tag matches nothing, silently

There are ~88 valid part-of-speech tags, and they're a hierarchy (#FirstName ⊂ #Person ⊂ #Noun). A #Tag that isn't real does not error — it just matches nothing, which looks like a logic bug. Common inventions that are NOT tags: #Name, #Location, #Subject, #Object, #Adj, #Entity. (Valid ones include #Person, #Place, #Organization, #Noun, #Verb, #Value, #Date.) When unsure, check node_modules/compromise/docs/tag-definitions.md.

3. Match-syntax is term-level, not regex

.match() matches whole words/terms, not characters. + * ? . ^ $ operate on terms. For character-level patterns, use a /regex/ token. Cheat sheet (see references for the rest):

TokenMeansExample
#Taga part-of-speech tag#Person
.any one termthe . sat
*any run of termsthe * sat
(a|b)one of these(cat|dog)
word?optional termthe big? cat
#Tag+one or more#Adjective+
!negate a termthe !#Verb
[ ] / [<name> ]capture group[<who>#Person+]
^ / $sentence start / end^the / sat$
~word~fuzzy / typo-tolerant~organization~
{root}match all conjugations{walk} matches walked/walking
/regex/character-level regex/colou?r/
js
nlp('John Smith left').match('[<who>#Person+]').groups('who').text()   // 'john smith'
4. Sentences are the ceiling — matches don't cross sentence boundaries

nlp("that's it. Back to Winnipeg!").has('it back') is false. For multi-sentence matching, use the compromise-paragraphs plugin.

Show full SKILL.md (240 more words)Show less
5. compromise is the full build — import it unless size is critical
  • import nlp from 'compromise' — full library: .people(), .verbs(), .numbers(), all selections. Default.
  • import nlp from 'compromise/two' — POS tags + .match(), but no named selections.
  • import nlp from 'compromise/tokenize' (/one) — tokenize only, no tags (#Tag patterns won't work).

There's no useful tree-shaking below these tiers; run the full build.

Common tasks (verified patterns)

js
// entities
nlp(text).people().out('array')        // ['Mary', 'Dr. John Smith']
nlp(text).topics().out('array')        // people + places + organizations
// NOTE: out('array') keeps trailing punctuation ('Paris.'); use .text('normal') for clean tokens

// transform (remember rule #1 — read from doc)
let d = nlp('I walk'); d.verbs().toPastTense(); d.text()      // 'I walked'
let n = nlp('one dog'); n.nouns().toPlural(); n.text()        // 'one dogs'

// numbers
nlp('five hundred').numbers().toNumber().text()   // '500'
nlp('it cost twelve dollars').numbers().get()     // [12]

// find / route (boolean, never mutates)
nlp('the deal is closed').has('#Determiner #Noun')   // true

// teach it words
nlp(text, { kermit: 'FirstName' })                // per-call lexicon
nlp.addWords({ frodo: 'FirstName' })              // global

Sharp edges to warn the user about (current behavior)

  • .redact() removes people, places, emails, and phone numbers — but not organizations, despite some docs saying otherwise. Redact orgs yourself: doc.organizations().replaceWith('███').
  • A few methods appear in older docs but do not exist and will throw: .money().currency(), .fractions().toText(), .percentages().toFraction(). Use .money().json() / .fractions().get() instead.
  • .out('array') and .text() include surrounding punctuation; .text('normal') or .json() normal give cleaned forms.

Debugging a wrong result

js
doc.debug()        // prints how every word was actually tagged — start here
doc.json()         // full structured data: terms, tags, offsets
nlp.verbose(true)  // log the tagger's decision-making

If .match() returns nothing: confirm the tag is real (rule #2), remember sentence boundaries (rule #4), and recall exact words match literally (use {root} for all conjugations).

Going deeper — read the version-matched docs in the installed package

The authoritative docs ship inside the package the project actually installed, so they match its exact version. Read these when you need more than the cheat sheet above:

  • node_modules/compromise/docs/match-syntax.md — every match operator, with examples
  • node_modules/compromise/docs/tag-definitions.md — the complete, valid tagset with the hierarchy
  • node_modules/compromise/docs/api.md — every method, signature, and description
  • node_modules/compromise/docs/recipes.md — copy-paste solutions to common tasks
  • node_modules/compromise/docs/concepts.md — the document/View/Term model in full

(When working inside the compromise repo itself, these are at docs/… and AGENTS.md.)

© spencermountain, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 8 other files in docs of spencermountain/compromise.

  • SKILL.md
  • api.md
  • concepts.md
  • development.md
  • match-syntax.md
  • recipes.md
  • spec-format.md
  • tag-definitions.md
  • tagging-differences.md

Open the folder on GitHubat commit 2e7a1b9

Compare with similar skills

Compromise NLP for JavaScript next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Compromise NLP for JavaScript compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Compromise NLP for JavaScript this skillspencermountain/compromise12k—~1.8kAutomated safety check: PassMIT
Tavily Search API Integrationandrewyng/context-hub14k—~1.1kAutomated safety check: PassMIT
Getting Startedlive-codes/livecodes1.5k—~1.6kAutomated safety check: PassMIT
Transformers.jshuggingface/skills11k1 repos~6.2kAutomated safety check: PassApache-2.0
Langgraph Project Setupsoba-labs/langchain-agent-skills107—~2.4kAutomated safety check: NotesMIT
Install Anti-Slop Oxlint Rulesdmmulroy/anti-slop5.4k—~2.2kAutomated safety check: PassMIT

Similar skills

  • Tavily Search API Integration

    andrewyng/context-hub

    Guides building Tavily integrations for web search, URL extraction, site crawling and AI-assisted research in Python or JavaScript agent and RAG projects.

    14k GitHub stars~1.1k tokensUpdated 4 mo ago
    AI & LLM EngineeringAuto-check passed
  • Getting Started

    live-codes/livecodes

    Quick start for standalone app at livecodes.io, embedding playgrounds with CDN or npm, and self-hosting basics.

    1.5k GitHub stars~1.6k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Transformers.js

    huggingface/skills

    Official

    Runs pre-trained Hugging Face models in JavaScript or TypeScript with Transformers.js, in browsers or Node.js, Bun and Deno, for text, vision, audio and multimodal tasks.

    11k GitHub starsUsed in 1 repo~6.2k tokens
    AI & LLM EngineeringAuto-check passed
  • Langgraph Project Setup

    soba-labs/langchain-agent-skills

    Initialize and configure LangGraph projects with proper structure, langgraph.json configuration, environment variables, and dependency management.

    107 GitHub stars~2.4k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Installs, updates or migrates the vendored anti-slop Oxlint plugin in a repository, keeping local rule changes and the plugin's license and provenance files.

    5.4k GitHub stars~2.2k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Release Round

    ethereumjs/ethereumjs-monorepo

    Runs a coordinated EthereumJS npm release round in six human-gated phases — intent and readiness, CHANGELOG, version bump, publish (human executes), post-publish verification, and announcements.

    2.8k GitHub stars~2k tokensUpdated 22 days ago
    DevelopmentAuto-check passed

More from spencermountain/compromise

  • Compromise NLP Library

    spencermountain/compromise

    Helps write and debug JavaScript or TypeScript that uses the compromise English NLP library for matching, entity extraction, tagging and sentence transforms.

    12k GitHub stars~2k tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Compromise NLP for JavaScript

What does Compromise NLP for JavaScript do?

Guide for writing correct code with the compromise rule-based NLP library: tagging, match syntax, in-place transforms and common tasks like tense changes and redaction. compromise is a rule-based English NLP library for JavaScript that needs no network, model or dependencies. You turn text into a document, the library tags each word's part of speech, and you find and transform parts of the text with a chained, jQuery-like API.

When should I use Compromise NLP for JavaScript?

Compromise NLP for JavaScript fits situations like: writing or editing JavaScript that imports compromise or calls nlp(); extracting people, places, dates or numbers from English text with rules; changing verb tense, pluralizing or normalizing text in JavaScript; redacting or anonymizing names in a block of text.

How do I install Compromise NLP for JavaScript in Claude Code?

Run `npx skills add spencermountain/compromise --skill compromise-nlp -a claude-code`. Or copy the skill folder (docs in spencermountain/compromise) into .claude/skills/compromise-nlp in your project. Claude Code loads it when a task matches its description.

How do I install Compromise NLP for JavaScript in Codex?

Run `npx skills add spencermountain/compromise --skill compromise-nlp -a codex`. Or copy the skill folder (docs in spencermountain/compromise) into .agents/skills/compromise-nlp in your project. Codex loads it when a task matches its description.

Can I use Compromise NLP for JavaScript in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add spencermountain/compromise --skill compromise-nlp -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/compromise-nlp, .gemini/skills/compromise-nlp, .github/skills/compromise-nlp and .opencode/skills/compromise-nlp in your project.

What does Compromise NLP for JavaScript need to run?

SKILL.md names no scripts, command-line tools or credentials: Compromise NLP for JavaScript is instructions for the agent only. Our summary lists: The compromise npm package.

Does Compromise NLP for JavaScript access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Compromise NLP for JavaScript safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Compromise NLP for JavaScript use?

Compromise NLP for JavaScript is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Compromise NLP for JavaScript use?

About 1.8k tokens (SKILL.md is roughly 7.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Compromise NLP for JavaScript?

Skills that share tags, products or a category with Compromise NLP for JavaScript: Tavily Search API Integration (andrewyng/context-hub, 14k stars), Getting Started (live-codes/livecodes, 1.5k stars), Transformers.js (huggingface/skills, 11k stars) and Langgraph Project Setup (soba-labs/langchain-agent-skills, 107 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Compromise NLP for JavaScript?

spencermountain (a GitHub user) maintains it in spencermountain/compromise, which has 12,162 GitHub stars. The repository holds 2 skills in this directory. The repository was last updated on October 9, 2026.

Source: spencermountain/compromise on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.