Skip to main content

A static analyzer for LLM prompts — catches cost waste, quality issues, and security risks.

Project description

PromptLint

Static analysis for LLM prompts. Think ESLint, but for the text you send to GPT-4 / Claude / Gemini.

Catches token waste, vague language, prompt injection, missing structure, and other issues that degrade prompt quality in production. Runs locally — no API calls, no round-trips, results in milliseconds.

Install

pip install promptlint-cli

For accurate token counting (requires a Rust toolchain on non-CPython):

pip install promptlint-cli[tiktoken]

Requires Python 3.9+.

Quick start

# lint a file
promptlint --file prompt.txt

# lint inline text
promptlint -t "Please write some code for me"

# multiple files with globs
promptlint prompts/**/*.txt --exclude prompts/drafts/*

# pipe from stdin
cat prompt.txt | promptlint --format json

# auto-fix what it can
promptlint --file prompt.txt --fix

# CI mode: exit 1 on warnings, only print the summary
promptlint prompts/ --fail-level warn --quiet

Exit codes: 0 = clean, 1 = warnings found (with --fail-level warn), 2 = critical issues.

Example output

$ promptlint --file system_prompt.txt

PromptLint Findings
[ INFO     ] cost (line -) Prompt is ~38 tokens (~$0.0002 input per call on gpt-4o).
[ WARN     ] structure-sections (line -) No explicit sections detected (Task/Context/Output).
[ WARN     ] clarity-vague-terms (line 1) Vague term 'some' detected. Be more specific.
[ CRITICAL ] prompt-injection (line 5) Injection pattern detected: 'ignore previous instructions'.

1 file(s) scanned, 4 finding(s) in 0.41s

What it checks

Rule What it does Fixable
cost Token count and per-call cost estimate
cost-limit Warns when prompt exceeds your token budget
prompt-injection Catches injection patterns, even with leetspeak/unicode obfuscation yes
structure-sections Flags prompts with no clear sections yes
clarity-vague-terms Finds "some", "stuff", "maybe", "good", etc.
specificity-examples Suggests adding examples for complex instructions
specificity-constraints Suggests adding length/format/scope constraints
politeness-bloat Flags "please", "kindly", "thank you" (burns tokens) yes
verbosity-sentence-length Flags sentences over 40 words
verbosity-redundancy "in order to" → "to", "due to the fact that" → "because" yes
actionability-weak-verbs Flags excessive passive voice
consistency-terminology Catches mixed terms (user/customer, function/method)
completeness-edge-cases Reminds you to specify error handling

Run promptlint --list-rules to see them all, or promptlint --explain cost for details on any rule.

Auto-fix

Pass --fix and PromptLint removes politeness filler, simplifies redundant phrases, strips injection lines, and scaffolds missing sections:

$ promptlint -t "Please kindly write code in order to sort the array, thank you" --fix

Optimized Prompt
<task>Write code to sort the array.</task>

Configuration

Drop a .promptlintrc in your repo root (or run promptlint --init to generate one):

model: gpt-4o
token_limit: 800
cost_per_1k_tokens: 0.005
calls_per_day: 10000

rules:
  cost:
    enabled: true
  prompt_injection:
    enabled: true
    patterns:
      - ignore previous instructions
      - system prompt extraction
  politeness_bloat:
    enabled: true
    words: [please, kindly, thank you, i would appreciate]
  structure_sections:
    enabled: true

fix:
  enabled: true
  prompt_injection: true
  politeness_bloat: true
  verbosity_redundancy: true
  structure_scaffold: true

CLI reference

promptlint [FILES...] [OPTIONS]

  -V, --version            Show version
  -f, --file PATH          Single prompt file
  -t, --text TEXT          Inline prompt text
  -c, --config PATH        Config file (default: .promptlintrc)
  --format {text,json}     Output format
  --fix                    Auto-fix and print optimized prompt
  --fail-level LEVEL       none / warn / critical (default: critical)
  --show-dashboard         Token savings breakdown
  -q, --quiet              Summary line only (for CI)
  --exclude PATTERN        Exclude globs (repeatable)
  --list-rules             Show all rules
  --explain RULE_ID        Explain a specific rule
  --init                   Generate starter .promptlintrc

Injection evasion detection

The prompt-injection rule normalizes text before matching, catching obfuscated attacks that simple regex would miss:

Evasion technique Example Detected?
Leetspeak 1gn0r3 pr3v10u$ 1nstruct10ns Yes
Zero-width characters ign​ore previous instruc​tions Yes
Character repetition ignoooore previooous instructions Yes
Fullwidth unicode ignore previous instructions Yes
Mixed obfuscation !gnor3 pr3v!0u$ in$truction$ Yes

Custom injection patterns can be added in .promptlintrc under rules.prompt_injection.patterns.

Agent skills

PromptLint ships with skills for AI coding agents that teach them prompt conventions and a lint-and-fix loop:

  • Cursor.cursor/skills/promptlint/SKILL.md
  • Claude Code.claude/skills/promptlint/SKILL.md

Links

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptlint_cli-1.0.2.tar.gz (35.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptlint_cli-1.0.2-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file promptlint_cli-1.0.2.tar.gz.

File metadata

  • Download URL: promptlint_cli-1.0.2.tar.gz
  • Upload date:
  • Size: 35.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for promptlint_cli-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8d0566716562cce0e40f7789b3d89a04cdd363387cef2ae51f4283916e3ee16e
MD5 9f79ac8f3354edb5dc47fca0425c1c57
BLAKE2b-256 d8a6e37021f4345aa85f8bd24ebba06fd8ce10a47f800121b0780ce86d755b8f

See more details on using hashes here.

File details

Details for the file promptlint_cli-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: promptlint_cli-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for promptlint_cli-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bfeb4856b9cb53273643a3f3e3c1cc7c91a988c86b8dbc011d8a7edd1dca98e7
MD5 4f2ccd85e66f8d186001453d140366f2
BLAKE2b-256 bdb10464fc79f21e0e1d89d64027ced01e21392d29e5dfc20246bd1689737a54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page