tonyandrewmeyer/cantrip/adding-actions
Claude Code and agent skill by tonyandrewmeyer/cantrip
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Implementing Juju actions for operational tasks in charms
Install
npx vskill@latest install tonyandrewmeyer/cantrip/adding-actionsSKILL.md
The same SKILL.md was published earlier as tonyandrewmeyer/cantrip/adding-actions.
Adding Actions to Charms
Juju actions are operator-triggered tasks — think "backup the database", "rotate credentials", or "dump debug info". They run on demand and return structured results.
Key Concepts
- Actions are for operational tasks — things an operator does occasionally, not things that happen automatically
- Actions run on a specific unit — invoked with
juju run <unit> <action> - Actions can accept parameters and return structured results
- Actions should be idempotent where possible — running the same action twice should be safe
Step 1: Define Actions in Metadata
Create or edit charmcraft.yaml to declare actions:
Parameter Types
Juju action parameters use JSON Schema types:
string— text valuesinteger— whole numbersnumber— floating-point numbersboolean— true/falsearray— lists (withitemsspecifying element type)object— nested structures
Step 2: Implement Action Handlers
Step 3: Handle Long-Running Actions
For actions that take time, use progress logging:
Step 4: Run Actions
Step 5: Test Actions with Scenario
Design Principles
- Actions are for operator-initiated tasks. Do not use actions for things that should happen automatically (use events/hooks for those).
- Return structured results. Use
event.set_results()with clear key-value pairs. Callers parse these programmatically.
- Fail explicitly. Call
event.fail("reason")with a descriptive message when an action cannot complete. Do not silently succeed.
- Leader-only actions. Some actions (like credential rotation) should only run on the leader. Check
self.unit.is_leader()and fail with a clear message if not.
- Use hyphens in action names (e.g.,
rotate-credentials). Juju converts hyphens to underscores for the Python event name (rotate_credentials_action).
- Document parameters clearly in the
charmcraft.yamlactionssection. Operators rely onjuju actions my-charmto understand what is available.
Common Pitfalls
- Forgetting the observer or the terminating call. Every declared action needs an observer, and the action-name → event-attribute mapping is
my-action→self.on.my_action_action;charmlintflags a declared action with no observer (ACTIONS-001). Every handler must also end by callingevent.set_results()orevent.fail(). - Modifying charm state in actions without guards — actions can run concurrently with hooks. Be careful about shared state.
- Returning sensitive data — action results are stored in Juju's database and visible to anyone with model access. Use Juju secrets for sensitive values.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingsrc/cantrip/skills/adding-actions/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tonyandrewmeyer/cantrip/adding-actions)