How Caveman Handles Different Languages: Portuguese, Spanish, and Beyond

Caveman preserves the user's dominant language by applying style compression while leaving the original language untouched, as defined in skills/caveman/SKILL.md and implemented in src/hooks/caveman-activate.js.

Caveman is an open-source text compression tool designed to reduce token count while maintaining clarity across multilingual inputs. Unlike systems that default to English output, Caveman respects the user's original language—whether Portuguese, Spanish, or others—ensuring that how Caveman handles different languages remains transparent and configurable through its skill-based architecture.

Language Preservation Rules

The foundation of Caveman's multilingual support lies in its skill definition. According to skills/caveman/SKILL.md at line 23, the rules explicitly mandate:

“Preserve user’s dominant language. User write Portuguese → reply Portuguese caveman. User write Spanish → reply Spanish caveman. Compress the style, not the language. No forced English openings or status phrases. ALWAYS keep technical terms, code, API names, CLI commands, commit‑type keywords (feat/fix/…), and exact error strings verbatim — unless user explicitly ask for translation.”

This directive ensures that the system distinguishes between stylistic elements (articles, filler words, hedging) and linguistic content (grammar, vocabulary, sentence structure). By targeting only the former, Caveman achieves compression without translation.

Implementation in the Activation Hook

The practical execution of language preservation occurs in src/hooks/caveman-activate.js at line 131. This hook activates the mode during each response cycle through the following process:

  1. Language Detection: The system analyzes the user’s input using simple heuristics, such as detecting non-ASCII words or language-specific stopwords
  2. Flag Setting: It sets a language flag corresponding to the detected dominant language
  3. Compression Application: The flag is passed to the response generator, which applies caveman-style compression—dropping articles and filler—while preserving the original language structure

The hook ensures that the compression engine operates on the token stream only after language detection completes, preventing any cross-linguistic interference.

Technical Architecture

Caveman's core engine does not perform language-specific tokenization. Instead, it works on the token stream after the language detection step, identifying universal patterns of verbosity common to formal writing. Because the compression rules affect only stylistic elements and never touch code blocks, API names, or technical terminology, the output token count is reduced without altering the language’s grammar or vocabulary.

Language Handling Examples

Portuguese Input Processing

When receiving Portuguese text, the system maintains Portuguese output while removing conversational filler:

Prompt:

Estou tentando conectar ao PostgreSQL mas recebo o erro “password authentication failed for user”.

Caveman Response (Full Intensity):

Erro “password authentication failed for user”. Verifique senha, usuário, host, porta. Use `psql` -U usuario -h host -p 5432.

The response remains in Portuguese; only filler and pleasantries have been stripped.

Spanish Input Processing

Spanish inputs similarly retain their linguistic identity through the compression process:

Prompt:

Mi aplicación se bloquea cuando llamo a la API REST y recibo un 500.

Caveman Response (Lite Intensity):

Bloqueo al llamar API REST, recibe 500. Revise logs, traceback, punto de fallo. Asegure que endpoint exista y que cuerpo sea válido.

The output stays in Spanish while achieving the terse caveman style.

Explicit Translation Override

The preservation rule includes a specific exception for translation requests. When users explicitly ask for translation, the system disables the preservation flag:

Prompt:

Estoy usando Node.js y quiero que me traduzcas al inglés antes de comprimir.

Caveman Response (Full Intensity):

Error “module not found” in Node.js. Check import path, file extension, and that the module is installed.

Because the user requested English translation, Caveman converts the language before applying compression, demonstrating the flexibility of the language flag logic.

Key Files for Multilingual Support

Several files work together to ensure Caveman respects the user's original language:

Summary

  • Caveman preserves the user's dominant language rather than defaulting to English, as defined in skills/caveman/SKILL.md
  • The language flag set in src/hooks/caveman-activate.js controls whether compression preserves or translates the input
  • Technical terms, code blocks, API names, and error strings remain verbatim regardless of the surrounding language
  • Language detection relies on simple heuristics before the compression engine processes the token stream
  • Users can override preservation by explicitly requesting translation in their prompt

Frequently Asked Questions

Does Caveman support all languages or only specific ones?

Caveman supports any language the underlying model can process. The system uses simple heuristics in src/hooks/caveman-activate.js to detect input language without requiring language-specific tokenization, making it compatible with Portuguese, Spanish, French, and others, provided the model recognizes the vocabulary.

How does Caveman handle mixed-language inputs?

The activation hook identifies the dominant language through heuristics like non-ASCII word patterns and stopword detection. While the specific logic for mixed inputs isn't explicitly segmented in the source, the system processes the token stream after language detection, suggesting it compresses based on the predominant detected language while protecting technical terms in their original form.

Can I force Caveman to output in English even if I write in Spanish?

Yes. The preservation rule in skills/caveman/SKILL.md includes an explicit exception: "unless user explicitly ask for translation." By requesting translation in your prompt, you disable the language preservation mechanism, allowing the system to translate to English before applying caveman-style compression.

Does language preservation affect how technical terms are handled?

No. The preservation rule explicitly mandates that technical terms, code, API names, CLI commands, commit-type keywords (feat/fix/etc.), and exact error strings remain verbatim regardless of language. This protection applies universally across all supported languages, ensuring that psql, npm install, or "password authentication failed" appear identically in Portuguese, Spanish, or English contexts.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →