Skip to main content

Token-efficient prompting and agentic workflows for Claude

Project description

promptkit-claude

Token-efficient prompting and agentic workflows for Claude.

Install

pip install promptkit-claude

Quick Start — Offline (no API key needed)

from claude_kit.compress import compress
from claude_kit.templates import summarize

# Remove filler phrases from any prompt (no API key needed)
prompt = compress("Please carefully analyze the following and provide a detailed summary")
# → "analyze the following and provide a summary"

# Build a token-efficient prompt
prompt = summarize(document, format="bullet", max_bullets=5)

Quick Start — With API Key

from claude_kit.cache import CachedClient

client = CachedClient()

# NOTE: First call warms the cache — expect 0% hit rate.
# Subsequent calls with the same system prompt hit the cache.
response = client.message(
    system="You are a helpful assistant with a long system prompt...",
    user="Hello!",
    cache_system=True,
)

print(client.cache_stats())
# → {"cache_hit_rate": "74%", "tokens_saved": 1840, "savings_usd": "$0.0023"}

Session Cost Tracking

from claude_kit.tracker import Tracker

with Tracker() as tracker:
    response = tracker.client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=1024,
        messages=[{"role": "user", "content": "Summarize quantum computing."}],
    )

print(tracker.summary())
# → {"input_tokens": 12, "output_tokens": 340, "total_cost_usd": "$0.0014"}

Agent Composition

from claude_kit.agent import Chain, Retry

# Chain: pipe output of one prompt into the next
result = Chain([
    "Summarize this document: {input}",
    "Extract action items from: {input}",
]).run(input=document)

# Retry: retry on failure with exponential backoff
safe_call = Retry(max_attempts=3).wrap(client.message)
response = safe_call(user="Tell me a joke.")

Async Support

from claude_kit.cache import AsyncCachedClient

client = AsyncCachedClient()

async def main():
    response = await client.message(
        system="You are a concise assistant.",
        user="What is 2 + 2?",
        cache_system=True,
    )
    return response

CLI

promptkit-claude compress "Please carefully explain this in detail"
# → "explain this in detail"

Modules

Module What it does Needs API key?
compress Removes filler phrases from prompts No
templates Token-efficient prompt templates No
tracker Session cost tracking Yes (wraps SDK)
cache CachedClient with cache_control Yes
agent Chain / Retry / Fallback / Parallel Yes

Versioning

We follow semver. Patch: bug fixes. Minor: new APIs, backwards compatible. Major: breaking changes with migration notes in CHANGELOG.

v0.2 Roadmap

  • Fallback and Parallel agent primitives with full test coverage
  • cache_tools support in CachedClient for tool-use payloads
  • templates.classify() and templates.extract() for common extraction tasks
  • Token budget warnings and hard caps via Tracker
  • Rich CLI output with cost breakdown per call
  • LangChain and LlamaIndex adapter shims

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

promptkit_claude-0.1.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

promptkit_claude-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file promptkit_claude-0.1.0.tar.gz.

File metadata

  • Download URL: promptkit_claude-0.1.0.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for promptkit_claude-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9b6d545882954ebe4a29f0e835fdcebe6d06464b6538e71bccfa5a0c9d97f835
MD5 23ffd027b2426331e199c256862c2a97
BLAKE2b-256 49dba959da029f1fa060742a4d1d675f6769c76ac1dd815f8668d8cf995d00b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for promptkit_claude-0.1.0.tar.gz:

Publisher: ci.yml on jasonstillchasin/claude-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file promptkit_claude-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for promptkit_claude-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 420c06ee92c020cd4e539b5900277653155d3607d9840fe867bb3a351b9e03f2
MD5 22c7ecc19bca7ac0d46b2d9135499513
BLAKE2b-256 bcd4eaf5c1896cd8c1c06b22d24a597c8873842e4dbfbe788b837f2d4e86767b

See more details on using hashes here.

Provenance

The following attestation bundles were made for promptkit_claude-0.1.0-py3-none-any.whl:

Publisher: ci.yml on jasonstillchasin/claude-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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