-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_plugin.py
More file actions
53 lines (37 loc) · 1.68 KB
/
export_plugin.py
File metadata and controls
53 lines (37 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Example: Select a subset of skills and export as a Claude plugin.
Demonstrates per-session skill narrowing — only expose the skills your agent
actually needs, reducing the skill surface area and avoiding tool overload.
Requires: pip install claude-agent-sdk
"""
import asyncio
from pathlib import Path
from claude_agent_sdk import ClaudeAgentOptions, query
import musher
# Credentials auto-discovered from MUSHER_API_KEY env var, keyring,
# or credential file. To override: musher.configure(token="your-token")
bundle = musher.pull("musher-examples/code-review-kit:1.2.0")
# Select only the skills needed for this session
selection = bundle.select(skills=["researching-repos", "drafting-release-notes"])
# Export as a local Claude plugin with a namespaced plugin name.
# Skills will be accessible as "code-review:researching-repos", etc.
plugin = selection.export_claude_plugin("code-review", dest=Path("./plugins"))
print(f"Plugin exported to: {plugin.path}")
# Verify only the selected skills are present
for skill in selection.skills():
print(f" Skill: {skill.name} — {skill.description}")
PROJECT_DIR = str(Path(__file__).resolve().parents[1])
async def main() -> None:
"""Query Claude with the exported plugin loaded."""
options = ClaudeAgentOptions(
cwd=PROJECT_DIR,
plugins=[{"type": "local", "path": str(plugin.path)}],
allowed_tools=["Skill", "Read", "Grep", "Glob", "Bash"],
max_turns=3,
)
async for message in query(
prompt="What custom commands do you have available?",
options=options,
):
print(message)
if __name__ == "__main__":
asyncio.run(main())