ワンクリックで
charm-improvement
Auditing and improving existing charms to modern standards
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Auditing and improving existing charms to modern standards
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | charm-improvement |
| description | Auditing and improving existing charms to modern standards |
Use this skill when improving an existing charm — auditing it against best practices, filling gaps, modernising code, and preparing it for Charmhub listing.
charm_audit on the charm directory to get a structured reportcharm_validate and the full test suite to verify everything worksEvery production charm should have these relations in charmcraft.yaml:
requires:
tracing:
interface: tracing
limit: 1
logging:
interface: loki_push_api
provides:
metrics-endpoint:
interface: prometheus_scrape
grafana-dashboard:
interface: grafana_dashboard
Add to requirements.txt:
ops-tracing >= 1.0
Add to src/charm.py:
import ops_tracing
class MyCharm(ops.CharmBase):
def __init__(self, framework):
super().__init__(framework)
self._tracing = ops_tracing.Tracing(self, "tracing")
The relation name passed to Tracing must match the tracing: entry under requires: in charmcraft.yaml. Do not use the legacy ops_tracing.setup(self) shorthand — it has been removed from ops-tracing.
ops-tracing instruments hooks, Pebble interactions, relations, status changes, and secrets automatically. Only add manual spans for long-running operations, external API calls, and fallback decision logic.
Use ops.testing (Scenario), not the deprecated Harness.
Key patterns:
import ops
import ops.testing
def test_start_ready():
ctx = ops.testing.Context(MyCharm)
container = ops.testing.Container("workload", can_connect=True)
state = ops.testing.State(containers=[container])
out = ctx.run(ctx.on.pebble_ready(container), state)
assert out.unit_status == ops.ActiveStatus()
Cover:
import jubilant
def test_deploy(juju: jubilant.Juju):
juju.deploy("./my-charm_amd64.charm", app="my-charm")
juju.wait(apps=["my-charm"], status="active")
def test_relate_database(juju: jubilant.Juju):
juju.deploy("postgresql-k8s", app="postgresql")
juju.relate("my-charm:database", "postgresql:database")
juju.wait(apps=["my-charm", "postgresql"], status="active")
If existing tests use from ops.testing import Harness, load the
harness-migration skill for the full per-file workflow, the detector script
that enumerates remaining Harness hits, and event-specific recipes. The short
form:
Harness(MyCharm) → ops.testing.Context(MyCharm)harness.begin() → not neededharness.charm.on.install.emit() → ctx.run(ctx.on.install(), state)harness.add_relation() → ops.testing.Relation(endpoint="db", interface="pgsql")| Deprecated | Replacement | Notes |
|---|---|---|
StoredState | Instance attributes, Juju secrets | StoredState has subtle persistence bugs |
Harness | ops.testing (Scenario) | Harness is deprecated since ops 2.x |
charmcraft fetch-libs | PyPI packages | PyPI versions are versioned and tested |
framework.breakpoint | Removed | Use standard Python debugging |
name: my-charm
display-name: My Charm
summary: One-line description of the charm
description: |
Detailed description of what the charm does,
how to deploy it, and key features.
docs: https://discourse.charmhub.io/t/my-charm-docs
issues: https://github.com/org/my-charm/issues
source: https://github.com/org/my-charm
tags:
- databases
A good README includes:
generate_icon to create a placeholder (coloured circle with the charm's initial) if missinggenerate_docs to create a docs/ directory with Diátaxis-structured documentation (tutorial, how-to, reference, explanation) using the Canonical starter pack; build locally with cd docs && make htmlcharmcraft pack should succeed with no warningsKnown-good Juju bundle shapes (COS Lite, 12-Factor + COS, Identity Platform, Charmed Kubeflow) — canonical app lists and relation edges
Implementing Juju actions for operational tasks in charms. WHEN: add Juju actions to a charm, implement backup / rotate-credentials / restore actions, declare actions in charmcraft.yaml, write action handlers, test actions with Scenario, run actions with juju run.
Adding and validating charm configuration options. WHEN: add charm configuration options, declare config in charmcraft.yaml, validate config values in config-changed, apply config to a Pebble layer, apply config to a machine charm, write Scenario tests for config.
End-to-end workflow for building ops-framework charms for custom applications (K8s and machine). WHEN: build a custom Juju charm, write src/charm.py with Pebble, write a machine charm with systemd, decide K8s vs machine substrate, scaffold a non-paas-charm with charmcraft init, customise the ops framework charm lifecycle.
Workflow for charming infrastructure software (databases, caches, message brokers, proxies, monitoring). WHEN: charm infrastructure software, charm a database / cache / message broker / proxy / monitoring system, implement peer relations, leader election, primary/replica failover, backup and restore actions, clustering.
Expert guidance for developing, building, testing, and publishing Juju charms using charmcraft. WHEN: edit charmcraft.yaml, run charmcraft pack, run charmcraft init, manage charm libraries, publish a charm to Charmhub, set up multi-base builds, configure relations / config options, set up storage or containers.