AGENTS.md · grafana/grafana
AGENTS.md from grafana/grafana: 181 lines covering Project Overview, Principles, Code Review Rules, Comments and more.
Template by grafana
Install
Works with Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/grafana/grafana/main/AGENTS.md -o AGENTS.md
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: prompt-engineering
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
An AGENTS.md file: instructions coding agents (Codex, Cursor, Copilot, Gemini CLI and others) read before working in a repo.
- For
- Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code
- Length
- 181 lines
- File
AGENTS.md
Sections
- Project Overview
- Principles
- Code Review Rules
- Comments
- Human Review Gates
- Commands
- Architecture
- Key Notes
- Cursor Cloud specific instructions
First lines (shown under the repo's AGPL-3.0 license)
# AGENTS.md <!-- version: 2.0.0 --> This file provides guidance to AI agents when working with code in the Grafana repository. **Directory-scoped agent files exist for specialized areas — read them when working in those directories:** - `docs/AGENTS.md` — Documentation style guide (for work under `docs/`) - `public/app/features/alerting/unified/AGENTS.md` — Alerting squad patterns - `pkg/storage/unified/AGENTS.md` — Unified storage/search compatibility rules (for work under `pkg/storage/unified/`) - `public/app/core/journeys/AGENTS.md` — Critical User Journey instrumentation ## Project Overview Grafana is a monitoring and observability platform. Go backend, TypeScript/React frontend, monorepo with pnpm workspaces (frontend) and Go workspaces (backend). ## Principles - Follow existing patterns in the surrounding code - Write tests for new functionality — for Go code, use `testing/synctest` over sleeps and time-based assertions; for frontend code, use the `frontend-testing-strategy` skill for this repo's testing conventions (and `panel-testing-strategy` on top of it for visualization/panel code) - Keep changes focused — avoid over-engineering - Separate PRs for frontend and backend changes (deployed at different cadences) - Security: prevent XSS, SQL injection, command injection - Security issues should be reported via [Grafana's security issue reporting page](https://grafana.com/legal/report-a-security-issue/) and not directly in this repository. ## Code Review Rules ### Metrics - Review metric changes against `contribute/backend/instrumentation.md`, especially registration, duplicate registration, label cardinality, and the impact of renames on dashboards and alerts. ## Comments - Only add a comment when it explains **why** something is done or reveals non-obvious logic that a reader must know to safely change the code. If the code is self-explanatory, no comment is needed. - Never include links (Slack, GitHub, Jira, etc.) in code comments. ## Human Review Gates Before running `git push`, stop and get explicit human approval. When changes are ready, show a summary of changes and wait for instruction. "Open a PR" in a task description is intent, not permission to push without review. ## Commands ### Build & Run ```bash make run # Backend with hot reload (localhost:3000, admin/admin) make build-backend # Backend only pnpm start # Frontend dev server (watches for changes) pnpm build # Frontend production build ``` ### Test ```bash # Backend go test -run TestName ./pkg/services/myservice/ # Specific test make test-go-unit # All unit tests make test-go-integration # Integration tests # Frontend pnpm test path/to/file # Specific file pnpm test -t "pattern" # By name pattern pnpm test -u # Update snapshots # E2E pnpm e2e:playwright path/to/test.spec.ts # Specific test ``` ### Lint & Format ```bash make lint-go # Go linter pnpm lint # ESLint pnpm lint:fix # ESLint auto-fix pnpm prettier:write # Prettier auto-format pnpm typecheck # TypeScript check ``` ### Code Generation ```bash make gen-go # Wire DI (after changing service init) make gen-cue # CUE schemas (after changing kinds/) make gen-apps # App SDK apps make swagger-gen # OpenAPI/Swagger specs make gen-feature-toggles # Feature flags (pkg/services/featuremgmt/) make i18n-extract # i18n strings make update-workspace # Go workspace (after adding modules) ``` ### Dev Environment ```bash pnpm install --frozen-lockfile # Install frontend deps make devenv sources=influxdb # Start backing services make devenv-down # Stop backing services make lefthook-install # Pre-commit hooks ``` ## Architecture ### Backend (`pkg/`) | Directory | Purpose | | ----------------- | ----------------------------------------------------------- | | `pkg/api/` | HTTP API handlers and routes | | `pkg/services/` | Business logic by domain (alerting, dashboards, auth, etc.) | | `pkg/server/` | Server init and Wire DI setup (`wire.go`) | | `pkg/tsdb/` | Time series database query backends | | `pkg/plugins/` | Plugin system and loader | | `pkg/infra/` | Logging, metrics, database access | | `pkg/middleware/` | HTTP middleware | | `pkg/setting/` | Configuration management | **Patterns**: Wire DI (regenerate with `make gen-go`), services implement interfaces in same package, business logic in `pkg/services/<domain>/` not in API handlers, database via `sqlstore`, plugin communication via gRPC/protobuf. ### Frontend (`public/app/`) | Directory | Purpose | | ---------------------- | ----------------------------------------------------- | | `public/app/core/` | Shared services, components, utilities | | `public/app/features/` | Feature code by domain (dashboard, alerting, explore) | | `public/app/plugins/` | Built-in plugins (many are pnpm workspaces) | | `public/app/types/` | TypeScript type definitions | | `public/app/store/` | Redux store configuration | **Patterns**: Redux Toolkit with slices (not old Redux), function components with hooks, Emotion CSS-in-JS via `useStyles2`, RTK Query for data fetching, React Testing Library for tests. ### Shared Packages (`packages/`) `@grafana/data` (data structures), `@grafana/ui` (components), `@grafana/runtime` (runtime services), `@grafana/schema` (CUE-generated types), `@grafana/scenes` (dashboard framework). ### Backend Apps (`apps/`) Standalone Go apps using Grafana App SDK: `apps/dashboard/`, `apps/folder/`, `apps/alerting/`. ### Plugin Workspaces These built-in plugins require separate build steps: `azuremonitor`, `loki`, `grafana-testdata-datasource`. Build a specific plugin: `pnpm --filter @grafana-plugins/<name> dev` ## Key Notes - When calling a unified storage gRPC client, handle both error forms (transport `err` and response `Error`) with the helpers described in `pkg/storage/unified/resource/doc.go`; never check only one of them. - **Wire DI**: Backend service init changes require `make gen-go`. Wire catches circular deps at compile time. - **CUE schemas**: Dashboard/panel schemas in `kinds/` generate both Go and TS code via `make gen-cue`. - **Feature toggles**: Defined in `pkg/services/featuremgmt/`, auto-generate code. Run `make gen-feature-toggles` after changes. - **Go workspace**: Defined in `go.work`. Run `make update-workspace` when adding Go modules. - **Build tags**: `oss` (default), `enterprise`, `pro`. - **Config**: Defaults in `conf/defaults.ini`, overrides in `conf/custom.ini`. - **Database migrations**: Live in `pkg/services/sqlstore/migrations/`. Test with `make devenv sources=postgres_tests,mysql_tests` then `make test-go-integration-postgres`. - **CI sharding**: Backend tests use `SHARD`/`SHARDS` env vars for parallelization. - **Backend test classification**: Use `TestIntegration*` for tests that need the SQL database matrix. SQLite-only tests and SQL-independent tests should run once in the normal suite. Follow the [backend testing guidelines](contribute/backend/style-guide.md#integration-tests) for short-mode guards, mixed-backend suites, and external-service tests. - **Metrics**: Before adding, renaming or registering metrics, read `contribute/backend/instrumentation.md` for naming and registration conventions. - **Service compatibility**: Unified storage/search (`pkg/storage/unified/`) can be deployed as separate services at a different cadence than the Grafana API layer. Changes spanning API-layer callers and `pkg/storage/unified/` must be backwards compatible in both directions — see `pkg/storage/unified/AGENTS.md`.
Signals
- Stars
- 77,477
- Forks
- 14,849
- Open issues
- 2,651
- Last commit (this folder)
- Oct 23, 2026 (5 days ago)
- Last release
- Oct 13, 2026 (15 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- AGPL-3.0
- Repository
- github.com/grafana/grafana
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from grafana
- 0.815score
MCP Grafana
grafanaOfficial
An MCP server giving access to Grafana dashboards, data and more.
ConnectorAFreshness: ARemoteLocal★ 3.6KClaude Code +5 - 0.673score
AGENTS.md · grafana/k6
grafana
AGENTS.md from grafana/k6: 191 lines covering Project Overview, Common Development Commands, Architecture Overview, Testing Structure and more.
TemplateBFreshness: B★ 32KCodex +5
Cite this page
AGENTS.md · grafana/grafana. Agent Mart. https://agentmart.dev/templates/grafana-grafana-agents-md (last updated 2026-10-24)