Shared Python utilities for building Claude Code Assistant Skills plugins
Project description
Assistant Skills Library
Shared Python utilities for building Claude Code Assistant Skills plugins.
Installation
pip install assistant-skills-lib
# With HTTP support (for requests-based error handling)
pip install assistant-skills-lib[http]
Quick Start
from assistant_skills_lib import (
format_table,
validate_url,
Cache,
handle_errors,
APIError,
)
# Format data as a table
data = [
{"name": "Alice", "role": "Admin"},
{"name": "Bob", "role": "User"},
]
print(format_table(data, headers=["name", "role"]))
# Validate input
url = validate_url("https://api.example.com")
# Cache API responses
cache = Cache(app_name="my-skill")
cache.set("user:123", {"name": "Alice"}, ttl=300)
user = cache.get("user:123")
# Handle errors with decorator
@handle_errors
def main():
# Your code here - errors are caught and formatted
pass
Modules
Formatters
Output formatting utilities for tables, trees, and colored text.
from assistant_skills_lib import (
format_table,
format_tree,
format_list,
format_json,
print_success,
print_error_formatted,
print_warning,
Colors,
)
# Table formatting
data = [{"id": 1, "name": "Item 1"}, {"id": 2, "name": "Item 2"}]
print(format_table(data, headers=["id", "name"]))
# Tree formatting
tree = {"root": {"child1": {}, "child2": {"grandchild": {}}}}
print(format_tree(tree))
# Colored output
print_success("Operation completed!")
print_warning("Check your configuration")
Validators
Input validation utilities with clear error messages.
from assistant_skills_lib import (
validate_url,
validate_required,
validate_name,
validate_path,
validate_choice,
InputValidationError,
)
# URL validation
url = validate_url("https://api.example.com")
# Required field validation
name = validate_required(user_input, "username")
# Name validation (alphanumeric, hyphens, underscores)
skill_name = validate_name("my-skill", field_name="skill name")
# Choice validation
status = validate_choice(value, choices=["active", "inactive"], field_name="status")
Cache
File-based response caching with TTL support.
from assistant_skills_lib import Cache, cached, get_cache, invalidate
# Direct cache usage
cache = Cache(app_name="my-skill", default_ttl=300)
cache.set("key", {"data": "value"})
value = cache.get("key")
# Decorator usage
@cached(ttl=600, app_name="my-skill")
def fetch_user(user_id):
return api.get_user(user_id)
# Global cache access
cache = get_cache("my-skill")
cache.clear()
# Invalidate by pattern
invalidate("user:", app_name="my-skill")
Error Handler
Exception hierarchy and error handling utilities.
from assistant_skills_lib import (
handle_errors,
handle_api_error,
APIError,
AuthenticationError,
NotFoundError,
RateLimitError,
print_error,
ErrorContext,
)
# Decorator for main functions
@handle_errors
def main():
# Exceptions are caught, formatted, and exit with appropriate code
pass
# Handle API response errors
def make_request():
response = requests.get(url)
if not response.ok:
handle_api_error(response, operation="fetch user")
# Context manager for detailed error context
with ErrorContext("creating resource", resource_id=123):
client.post("/api/resources", data=data)
# Raise specific errors
raise NotFoundError("User not found", status_code=404)
raise RateLimitError("Too many requests", retry_after=60)
Template Engine
Template loading and rendering with placeholder support.
from assistant_skills_lib import (
load_template,
render_template,
list_placeholders,
list_template_files,
)
# Load and render templates
template = load_template("templates/skill.md")
content = render_template(template, {
"SKILL_NAME": "my-skill",
"DESCRIPTION": "A helpful skill",
})
# List placeholders in a template
placeholders = list_placeholders(template)
# Returns: ["SKILL_NAME", "DESCRIPTION", ...]
Project Detector
Detect and analyze Assistant Skills project structure.
from assistant_skills_lib import (
detect_project,
list_skills,
validate_structure,
get_project_stats,
)
# Detect project type
project = detect_project("/path/to/project")
# Returns: {"name": "Jira-Assistant-Skills", "type": "assistant-skills", ...}
# List skills in a project
skills = list_skills("/path/to/project")
# Returns: [{"name": "search", "path": "...", "has_scripts": True}, ...]
# Validate project structure
result = validate_structure("/path/to/project")
# Returns: {"valid": True, "errors": [], "warnings": [...]}
# Get project statistics
stats = get_project_stats("/path/to/project")
# Returns: {"skills": 5, "scripts": 12, "templates": 8, ...}
Development
# Clone the repository
git clone https://github.com/grandcamel/assistant-skills-lib.git
cd assistant-skills-lib
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
ruff check src/
# Type checking
mypy src/
License
MIT License - see LICENSE for details.
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
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 assistant_skills_lib-0.2.1.tar.gz.
File metadata
- Download URL: assistant_skills_lib-0.2.1.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70645006fd10bfa5ee258b958ac7eddc7662ac002442199ebf98e91346c0d512
|
|
| MD5 |
b316befb96b6b3a38c2f6b97327482b8
|
|
| BLAKE2b-256 |
1b79ff4257bd637d3a6db3108ec118ec2d6fbd4fa159a8679483e70dc335562c
|
Provenance
The following attestation bundles were made for assistant_skills_lib-0.2.1.tar.gz:
Publisher:
publish.yml on grandcamel/assistant-skills-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
assistant_skills_lib-0.2.1.tar.gz -
Subject digest:
70645006fd10bfa5ee258b958ac7eddc7662ac002442199ebf98e91346c0d512 - Sigstore transparency entry: 784596823
- Sigstore integration time:
-
Permalink:
grandcamel/assistant-skills-lib@d8c677d11013b2c9a032e8e2cce667289dc8b645 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/grandcamel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d8c677d11013b2c9a032e8e2cce667289dc8b645 -
Trigger Event:
release
-
Statement type:
File details
Details for the file assistant_skills_lib-0.2.1-py3-none-any.whl.
File metadata
- Download URL: assistant_skills_lib-0.2.1-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08a166dd53a7c9913a0f5de45b370f330f99eeb5a6fc6569aab94eee871a1206
|
|
| MD5 |
edfd1a528546a371f5046c110795c518
|
|
| BLAKE2b-256 |
9a33d70f580e3e4903b2359016078887a9482f7981f0780e27e60c23caeb485c
|
Provenance
The following attestation bundles were made for assistant_skills_lib-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on grandcamel/assistant-skills-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
assistant_skills_lib-0.2.1-py3-none-any.whl -
Subject digest:
08a166dd53a7c9913a0f5de45b370f330f99eeb5a6fc6569aab94eee871a1206 - Sigstore transparency entry: 784596894
- Sigstore integration time:
-
Permalink:
grandcamel/assistant-skills-lib@d8c677d11013b2c9a032e8e2cce667289dc8b645 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/grandcamel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d8c677d11013b2c9a032e8e2cce667289dc8b645 -
Trigger Event:
release
-
Statement type: