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
FallbackandParallelagent primitives with full test coveragecache_toolssupport inCachedClientfor tool-use payloadstemplates.classify()andtemplates.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b6d545882954ebe4a29f0e835fdcebe6d06464b6538e71bccfa5a0c9d97f835
|
|
| MD5 |
23ffd027b2426331e199c256862c2a97
|
|
| BLAKE2b-256 |
49dba959da029f1fa060742a4d1d675f6769c76ac1dd815f8668d8cf995d00b4
|
Provenance
The following attestation bundles were made for promptkit_claude-0.1.0.tar.gz:
Publisher:
ci.yml on jasonstillchasin/claude-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptkit_claude-0.1.0.tar.gz -
Subject digest:
9b6d545882954ebe4a29f0e835fdcebe6d06464b6538e71bccfa5a0c9d97f835 - Sigstore transparency entry: 1837716441
- Sigstore integration time:
-
Permalink:
jasonstillchasin/claude-kit@f3526d9471374b064e7380c06cdc0b4ef8046b69 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jasonstillchasin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@f3526d9471374b064e7380c06cdc0b4ef8046b69 -
Trigger Event:
push
-
Statement type:
File details
Details for the file promptkit_claude-0.1.0-py3-none-any.whl.
File metadata
- Download URL: promptkit_claude-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
420c06ee92c020cd4e539b5900277653155d3607d9840fe867bb3a351b9e03f2
|
|
| MD5 |
22c7ecc19bca7ac0d46b2d9135499513
|
|
| BLAKE2b-256 |
bcd4eaf5c1896cd8c1c06b22d24a597c8873842e4dbfbe788b837f2d4e86767b
|
Provenance
The following attestation bundles were made for promptkit_claude-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on jasonstillchasin/claude-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptkit_claude-0.1.0-py3-none-any.whl -
Subject digest:
420c06ee92c020cd4e539b5900277653155d3607d9840fe867bb3a351b9e03f2 - Sigstore transparency entry: 1837716559
- Sigstore integration time:
-
Permalink:
jasonstillchasin/claude-kit@f3526d9471374b064e7380c06cdc0b4ef8046b69 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jasonstillchasin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@f3526d9471374b064e7380c06cdc0b4ef8046b69 -
Trigger Event:
push
-
Statement type: