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

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 "ignore previous instructions" and similar 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

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.0.tar.gz (32.3 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.0-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: promptlint_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 32.3 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.0.tar.gz
Algorithm Hash digest
SHA256 189c07373daf1f68f6d3ad2e43cb6bb0fb210a8fc19cbeaddb29bfb42ae187fb
MD5 40c6cb9b9cb2f51041444bebd5818f55
BLAKE2b-256 a7e5c0c6c45cce3f94e6f7d01cd45367fe9eb5af337a5e24e76aec8584e24cac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: promptlint_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f03efa2802a187e33d93856d4385dfe7e4c010bff1ba47061853e33af92e8f78
MD5 1173297c1e853759313c5bbd48d2816e
BLAKE2b-256 6a8b714992d3c981e492f2e8dcb8f115c28e2d4c389484ff66f9dbb2eb5477b0

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