Skip to content

weli-dev/ai-summarizer

Repository files navigation

AI Text Summarizer

A small command-line tool that reads text from a file or stdin, sends it to Anthropic's Claude Haiku, and prints a clean 2-3 sentence summary plus five category tags.

Standard-library Python only — no external dependencies to install. Works the moment you have your API key set.


What it does

  • Reads input from a file argument OR from stdin (pipeable, chainable with other tools).
  • Sends the text to Anthropic's Messages API using claude-haiku-4-5 — fast, cheap, and accurate enough for summarization.
  • Enforces a strict JSON response shape via system prompt: {summary, tags[]}.
  • Strips accidental markdown fences from the model's response before parsing.
  • Prints the summary and tags to stdout, formatted for a terminal.

Uses urllib from the standard library — no requests, no pip install anthropic. If your Python runs, this script runs.


Setup

Export your Anthropic API key:

export ANTHROPIC_API_KEY="sk-ant-..."

Usage

Three ways to feed it text:

python summarize.py article.txt
cat article.txt | python summarize.py
echo "Some text to summarize." | python summarize.py

Sample output:

Summarizing 1,547 characters with claude-haiku-4-5-20251001 ...

Summary
────────────────────────────────────────────────────────────
The article argues that <point one>. <Point two connecting to
main claim>. <Practical takeaway>.

Tags
────────────────────────────────────────────────────────────
  technology  ·  policy  ·  startups  ·  automation  ·  labor

A sample article (sample-article.txt) is included so you can try the tool without hunting for text to summarize.


Deliverable & screenshots


Built by

I build AI-agent and automation systems — Claude Code / MCP integrations, LLM-into-workflow tooling, scrapers, and scripts that kill repetitive work. If you need an AI-powered tool wired into your real systems, that's the work I do.


License

MIT — use it, fork it, ship it.

About

Stdlib-only Python CLI that summarizes and tags text using Claude Haiku via the Anthropic API. Reads from files or stdin.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages