Skip to content
Development
Skill

/generate-resource-stubs

Generates typed Go stubs and grafana-foundation-sdk builder boilerplate for dashboards and alert rules. Use only when the user asks for stubs or builder boilerplate. To design a usable dashboard, use create-dashboard.

From plugin
gcx
81024 skills1 agent

Claude Code

$ npx -y skills add grafana/gcx --skill generate-resource-stubs --agent claude-code

SKILL.md

generate-resource-stubs.SKILL.md
name: generate-resource-stubs
description: >-
  Generates typed Go stubs and grafana-foundation-sdk builder boilerplate for
  dashboards and alert rules. Use only when the user asks for stubs or builder
  boilerplate. To design a usable dashboard, use create-dashboard.

Generate Typed Resource Stubs

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.

This skill stops at scaffolding. If the task is to decide which dashboard panels, variables, queries, and layout should exist, use `create-dashboard` after generating the stub.

Quick Start

# 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

How Type Inference Works

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

Output

  • Filename is normalized to snake_case: `my-dashboard.go` → `my_dashboard.go`
  • Function name is CamelCase: `my-dashboard` → `MyDashboard()`
  • Package name is derived from the parent directory

After Generation: Building Real Dashboards

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.

Dashboard Customization Cheat Sheet

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)

Alert Rule Customization Cheat Sheet

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.",
    })

Common Issues

| 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` |

Read more
@grafana
Ships withgcx

gcx is Grafana in your terminal and your agentic coding environment. With gcx you don't guess, but check the actual data.

81024 skills1 agent
Get the whole plugin

Stars on GitHub

Momentum

stars in total
810
Star history of grafana/gcx on GitHub, a chart by star-history.com

Other skills on gcx.

agento11y-instrument

agento11y-instrument

Instruments a developer's own LLM app or repairs missing generations and empty Performance charts in Grafana Agent Observability.…

@grafana@grafanaInstall Skill
agento11y-prod-setup

agento11y-prod-setup

Sets up production evaluation for a deployed AI agent in Agent Observability: online eval rules and guards (redact PII, block…

@grafana@grafanaInstall Skill
agento11y-test-starter

agento11y-test-starter

Builds a starter offline test suite for an AI agent before it ships: test cases from its code, scoring advice, and a runner stub.…

@grafana@grafanaInstall Skill
agento11y

agento11y

Inspects and manages Grafana Agent Observability resources via gcx: conversations, generations, experiments, evaluators, rules,…

@grafana@grafanaInstall Skill
create-dashboard

create-dashboard

Designs and creates Grafana dashboards with gcx, with `gcx dashboards snapshot` as a visual feedback loop. Use to build a new…

@grafana@grafanaInstall Skill
debug-with-grafana

debug-with-grafana

Investigates application problems and incidents with Grafana metrics, logs, and traces via gcx: errors, latency, regressions,…

@grafana@grafanaInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills11d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc13d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about generate-resource-stubs.

Which coding agents can use generate-resource-stubs?
generate-resource-stubs installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.