tonyandrewmeyer/charming-with-claude/layer-from-rockcraft
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/layer-from-rockcraftSKILL.md
The same SKILL.md was published earlier as tonyandrewmeyer/charming-with-claude/layer-from-rockcraft.
Skill: Adopt layer_from_rockcraft in Tests
Replace manually constructed Pebble layers in unit tests with testing.layer_from_rockcraft() to keep tests in sync with rockcraft.yaml.
When to Use
Use this when a K8s charm's unit tests manually construct ops.pebble.Layer objects with service definitions that duplicate what's in the charm's rockcraft.yaml.
Prerequisites
- ops >= 2.23.0
- The charm is a K8s charm with a
rockcraft.yamlfile - The charm has unit tests that construct Pebble layers for
testing.Container
Step 1: Identify Manual Layer Construction
Search test files for:
ops.pebble.Layer({orpebble.Layer({layers={intesting.Container()constructor calls- Service definitions in test code that duplicate
rockcraft.yaml
Step 2: Replace with layer_from_rockcraft
Path Resolution
The path is relative to where the tests are run (typically the project root). Common patterns:
testing.layer_from_rockcraft("rockcraft.yaml")— rock in the project roottesting.layer_from_rockcraft("../rock/rockcraft.yaml")— rock in a sibling directory
What Gets Extracted
The function reads summary, description, services, and checks from the rockcraft.yaml and constructs a pebble.Layer. All other rockcraft fields (name, base, parts, platforms) are ignored.
Step 3: Keep Charm-Specific Layers Separate
Tests typically need two layers:
- The rock layer (from
layer_from_rockcraft) — the base services from the rock - The charm's config layer — what the charm adds on top (environment overrides, etc.)
The test should assert that the charm correctly adds its config layer:
Step 4: Verify
- Run unit tests — they should pass with identical behaviour.
- Review the diff — the test should be simpler, with the duplicated service definitions removed.
Exemplar Charms
No production charm has adopted this yet. Best references:
- [ops documentation](https://github.com/canonical/operator/blob/main/docs/howto/manage-containers/manage-the-workload-container.md) — official how-to example.
- [ops test suite](https://github.com/canonical/operator/blob/main/testing/tests/test_e2e/test_state.py) —
test_layer_from_rockcraftparametrised tests.
Common Mistakes
- Don't remove layers that the charm adds on top of the rock layer — only replace the base rock layer duplication.
- Don't use this for charms that don't have a
rockcraft.yaml(e.g. charms that use a third-party image). - Make sure the path to
rockcraft.yamlis correct relative to the test runner's working directory.
Security
- Security scanPassed, 98 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/layer-from-rockcraft/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/charming-with-claude/layer-from-rockcraft)