From gcx
Generates typed Go stubs for Grafana dashboards and alert rules using grafana-foundation-sdk builder pattern via gcx dev generate. Infers type from dashboards/ or alerts/ directories.
How this skill is triggered — by the user, by Claude, or both
Slash command
/gcx:generate-resource-stubsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate ready-to-edit Go files for dashboards and alert rules using
Generate ready-to-edit Go files for dashboards and alert rules using
gcx dev generate. The generated code uses the grafana-foundation-sdk
builder pattern and compiles without modification.
# Dashboard stub
gcx dev generate dashboards/my-service-overview.go
# Alert rule stub
gcx dev generate alerts/high-cpu-usage.go
# Batch generation
gcx dev generate dashboards/a.go dashboards/b.go alerts/c.go
The resource type is inferred from the immediate parent directory:
| Directory | Type |
|---|---|
dashboards/ or dashboard/ | dashboard |
alerts/, alertrules/, or alertrule/ | alertrule |
Override with --type when the directory doesn't match:
gcx dev generate internal/monitoring/cpu-alert.go --type alertrule
my-dashboard.go → my_dashboard.gomy-dashboard → MyDashboard()The generated stub is a starting point. See references/foundation-sdk-guide.md
for the full builder API reference to customize your dashboards and alerts.
import (
dashboard "github.com/grafana/grafana-foundation-sdk/go/dashboardv2beta1"
"github.com/grafana/grafana-foundation-sdk/go/prometheus"
"github.com/grafana/grafana-foundation-sdk/go/timeseries"
)
builder := dashboard.NewDashboardBuilder("My Dashboard").
Tags([]string{"team:platform", "env:production"}).
Editable(true).
// Add a panel
Panel("requests-panel",
dashboard.NewPanelBuilder().
Title("Request Rate").
Visualization(timeseries.NewVisualizationBuilder()).
Data(
dashboard.NewQueryGroupBuilder().
Target(
dashboard.NewTargetBuilder().Query(
prometheus.NewDataqueryBuilder().
Expr(`rate(http_requests_total[$__rate_interval])`).
LegendFormat("{{method}} {{status}}"),
),
),
),
).
// Layout
AutoGridLayout(
dashboard.AutoGrid().
WithItem("requests-panel"),
)
return dashboard.Manifest("my-dashboard", builder)
import (
"github.com/grafana/grafana-foundation-sdk/go/alerting"
"github.com/grafana/grafana-foundation-sdk/go/resource"
)
rule := alerting.NewRuleBuilder("High CPU Usage").
Condition("A").
For("5m").
FolderUID("my-folder").
RuleGroup("cpu-alerts").
Labels(map[string]string{
"severity": "critical",
"team": "platform",
}).
Annotations(map[string]string{
"summary": "CPU usage above 90% for 5 minutes",
"description": "Instance {{ $labels.instance }} has high CPU usage.",
})
| Issue | Fix |
|---|---|
| "cannot infer resource type" | Directory name doesn't match known types; use --type dashboard or --type alertrule |
| "file already exists" | Delete the existing file first or use a different name |
| Need to add to registry | Manually add the function call to your All() function in all.go |
npx claudepluginhub grafana/gcx --plugin gcxScaffolds new Go projects for Grafana resources-as-code using gcx dev scaffold. Generates repo structure with CI/CD, main.go, and dashboard examples. Triggers on 'new project', 'scaffold', 'get started with gcx'.
Scaffolds Grafana plugin projects (panel, data source, app, backend) using @grafana/create-plugin. Automates Docker dev environment setup with hot-reload and plugin configuration for v12.x+.
Authors CUE kind definitions for grafana-app-sdk apps: schemas, versioning, field constraints, named types, custom routes, and codegen configuration. Scaffolds kinds and runs code generation.