tonyandrewmeyer/charming-with-claude/action-classes
Claude Code and agent skill by tonyandrewmeyer/charming-with-claude
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install tonyandrewmeyer/charming-with-claude/action-classesSKILL.md
The same SKILL.md was published earlier as tonyandrewmeyer/charming-with-claude/action-classes.
Skill: Adopt Action Classes
Replace raw event.params dictionary access with typed Python classes using ActionEvent.load_params().
When to Use
Use this when a charm has actions with parameters accessed via event.params["key"] or event.params.get("key").
Prerequisites
- ops >= 2.23.0
- The charm has actions defined in
charmcraft.yaml(oractions.yaml)
Step 1: Audit Current Action Usage
- Read the charm's action definitions to understand all actions and their parameters.
- Search charm code for action handlers (methods observing
self.on.*_action). - For each handler, note how
event.paramsis accessed and any manual validation.
Step 2: Define Action Parameter Classes
Create a class for each action's parameters. Use @dataclasses.dataclass(frozen=True, kw_only=True).
Or with Pydantic for richer validation:
Field Naming
Same rules as config: dashes become underscores automatically. Use aliases for exceptions.
Where to Put Them
For charms with several actions, create a separate src/action_types.py module. For one or two simple actions, inline in the charm module is fine.
Step 3: Update Action Handlers
Key: always use errors="fail" for actions. This automatically calls event.fail() with the validation error message if parameters are invalid.
Step 4: Update Tests
Action tests that set params via the testing framework should continue to work:
Step 5: Verify
- Run linting and unit tests.
- Check that
juju run <unit> <action> --param key=valuestill works as expected.
Exemplar Charms
- [ubuntu-autopkgtest-operators](https://github.com/canonical/ubuntu-autopkgtest-operators) (charms/autopkgtest-dispatcher-operator) — Pydantic with
Field(description=), Enum types,errors="fail". Separatesrc/action_types.py. - [canonical/operator](https://github.com/canonical/operator) (examples/k8s-4-action) — Official tutorial example with dataclasses.
Common Mistakes
- Don't forget
errors="fail"— the defaulterrors="raise"will cause an unhandled exception. - Don't add params classes for actions that take no parameters.
- Don't change action result keys or formats — only the input parameter handling is changing.
Security
- Security scanPassed, 100 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 repositoryCheckingexperiments/2026-01-25-ops-upgrade/skills/action-classes/SKILL.md
Popularity
- Repository stars
- 3
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. 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/charming-with-claude/action-classes)