/harness:write-hqlfrom Harness DevOps
Writes, validates, and runs HQL queries against Harness data for dashboard widgets and pipeline/deployment/CI/security analysis. Covers type discovery, syntax, and validation.
Ships in Harness DevOps. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Write, validate, and run HQL queries against Harness data, primarily for dashboard widget creation. This skill teaches the query language, the type discovery workflow, and the validation loop. For non-dashboard multi-query analysis (overview, drill-down, synthesis), also follow analysis-workflow.md.
Read the companion files in this skill directory before writing any queries:
reference.md — practical examples, type casting rules, JOIN syntax, anti-patterns.references/patterns/*.md — worked query patterns per question shape (failure-diagnosis, build-time-analysis, bottleneck-analysis, flakiness, retry-signals, intermittent-vs-consistent, lint-first, batch).references/entity-reference/ci.md — CI-native field discipline (stage_build_time vs duration, start_timestamp vs start_ts).Fetch the live grammar via harness_get(resource_type='kg_grammar') only when the reference files do not cover the syntax you need.
harness_list(resource_type='kg_queryable_type_summary')
You can filter by object kind to reduce the response:
harness_list(resource_type='kg_queryable_type_summary', kinds=['OBJECT_KIND_VIEW'])
This returns lightweight summaries: identifier (type_id for HQL), name, description, kind (OBJECT_KIND_*), connectorId, tags. Pick 1-5 types relevant to the user's question.
IMPORTANT: The only valid filter parameters are kinds (OBJECT_KIND_*) and annotations. Do NOT pass filters, name, compact, or any other made-up parameters — they are silently ignored and you will get the full unfiltered list.
Treat the returned list as authoritative and complete: if a type is not in it, you cannot query it. Do not guess or recall identifiers from earlier conversations, other accounts, or examples.
Selection criteria:
connectorId for each selected type — you need this for JOIN rulesFor each type you selected in Step 1, fetch its full field metadata using the semantic-layer kg_type resource. Always pass params.kind explicitly, using the exact kind value Step 1 returned for that identifier — never omit it. If kind is omitted, kg_type silently defaults to OBJECT_KIND_ENTITY, which may not be the queryable type you selected in Step 1.
List-first rule: resource_id MUST be an identifier that appeared in a Step-1 harness_list response earlier in this session. Do not fetch a type by a guessed, memorized, or copied-from-example identifier. If you need a type you have not listed, run Step 1 first.
harness_get(resource_type='kg_type', resource_id='<identifier-from-Step-1>', params={kind: '<kind-from-Step-1>'})
<identifier-from-Step-1> and <kind-from-Step-1> are placeholders — substitute the exact identifier and kind values a Step-1 response returned. Do not invent literal type ids.
Make one call per selected type (1-5 types). Each returns a single type with its fields (~5-15KB).
From each response, note:
field_type values — especially FIELD_TYPE_LONG vs FIELD_TYPE_TIMESTAMP for time fields (see reference.md Type Casting section)JOIN CONSTRAINT: You may ONLY join types that share the same connectorId. Types in different connector groups use different data sources and CANNOT be joined. When the user's question requires data from types in different connector groups, execute separate queries and correlate results in your analysis.
Group your selected types by connectorId:
Always validate before executing:
harness_execute(resource_type='hql_query', action='validate',
body={query_string: '<your HQL query>'})
Apply repair suggestions verbatim. Max 3 attempts (initial + 2 repairs). Repairs fix typos/syntax only — never drop filters, change aggregates, or alter ORDER BY direction. Unrepairable after 3 attempts → stop with a note. See references/patterns/lint-first.md.
Common fixes:
group_by for non-aggregated SELECT columnsharness_execute(resource_type='hql_query', action='run',
body={query_string: '<validated HQL query>', max_results: 100})
timeout_ms and max_results are optional. HQL is read-only, so running a query never changes data.
Assume generated HQL is for a dashboard widget unless the user explicitly asks for ad hoc analysis, a one-off query run, or a non-dashboard report. Unless the question is explicitly scope-agnostic or time-agnostic, every query must include:
account_identifier filter, plus org_identifier and project_identifier when the user names an org or project (or has configured default org/project for the MCP server). If the user gives a Harness UI URL, take the scope from it: /projects/<id> → project scope; /orgs/<id> without /projects/ → org scope; otherwise account scope. If scope is unclear, ask the user rather than guessing.{time_field} >= ${start_time} and {time_field} <= ${end_time}. Use ago(...) only for non-dashboard/ad hoc analysis. For non-dashboard recency, default to ago(7d) and do not exceed ago(30d) unless the user explicitly asks for a longer range and confirms they want to bypass this limit.status = 'FAILED' for failure-diagnosis questions.When writing HQL for a dashboard widget, the query must include the dashboard time predicates on the widget's selected Time Field by default. Do not rely on the widget UI alone, and do not replace this with ago(...) unless the user is not building a dashboard widget.
Use this shape, substituting the discovered field name selected in the widget's Time Field control:
| filter <time_field> >= ${start_time} and <time_field> <= ${end_time}
Generic dashboard widget query shape:
find entity "{module}:{entity}" | filter {required_predicates} and {time_field} >= ${start_time} and {time_field} <= ${end_time} | select { {aggregate_expression} as {alias} }
Keep any required business predicates in the same filter as the dashboard time predicate.
When reviewing or sharing a dashboard query with a customer, check whether the query already includes the ${start_time} and ${end_time} predicate on the same field selected as the widget Time Field. If it is missing, suggest adding that predicate so the dashboard time range applies to the query.
These files teach the shape of a query for a given question type — how to rank, join, aggregate, and window. They do not dictate which entity to use: the correct entity always comes from your Step-1/Step-2 discovery for this account. A "bottleneck" question may resolve to pipeline stages, CI stages, CCM cost, or a security scan queue depending on what discovery surfaces.
Placeholder convention. Worked queries in the pattern files are templates, not copy-paste queries. They use {...} placeholders you fill from discovery:
{module}:{entity} — a queryable type_id. {module} is the domain the question resolves to (pipeline, cd, ci, ccm, sto, chaos, ...) and {entity} the specific type — both taken from your Step-1 listing, never assumed. Even pipeline is just one module; the same shape applies under any module whose discovery surfaced a matching entity.{duration}, {start_time}, {status}, ... — field names confirmed via Step-2 kg_type for the chosen entity (sibling entities diverge: duration vs stage_build_time, start_ts vs start_timestamp).The transferable lesson is the structure around the placeholders (which aggregates, which joins, which filters) — not the placeholder values.
references/patterns/failure-diagnosis.md — traverse an execution hierarchy to the failing leaf; filter to the failed rows.references/patterns/build-time-analysis.md — rank by duration on successful runs; pair avg/p95/max.references/patterns/bottleneck-analysis.md — rank sub-units by latency; percentiles over averages.references/patterns/flakiness.md — combine retry, FAIL-then-PASS, and marked-flake signals when the discovered entities expose them.references/patterns/retry-signals.md — attribute retries down a join chain using discovered join keys.references/patterns/intermittent-vs-consistent.md — classify by status distribution per group.references/patterns/lint-first.md — validate before execute, 3-attempt semantic-preserving repair ladder.references/patterns/batch.md — batching rules (≤20 validate, ≤10 execute).references/entity-reference/ci.md — CI-native field-name examples (illustrative; confirm via kg_type)./write-hql
Write an HQL query for the pipelines that failed most often in the last 7 days in project my_proj.
Expected flow: list queryable types, pick the pipeline execution type, fetch its fields, build the query from references/patterns/failure-diagnosis.md, validate it, then run it.
/write-hql
This HQL fails validation, fix it: find entity "pipeline:pipeline_execution" | select {status, count()}
Expected flow: validate, read the errors, and repair syntax only (here, the missing group_by status).
/write-hql
Which types can I query for security issues, and what fields do they have?
kg_queryable_type_summary, not the grammar. Summaries are small; the grammar is large.kinds on the list call to cut the response size.kg_type only for the 1-5 types you will use, one call per type.limit, and prefer aggregates over raw rows for large populations.references/patterns/batch.md.kg_queryable_type_summary or hql_query is not availableThe MCP server is missing the knowledge-graph toolset. It is enabled by default; if HARNESS_TOOLSETS is set, make sure it includes knowledge-graph and semantic-layer.
kg_type is not availablekg_type belongs to the semantic-layer toolset. Enable it alongside knowledge-graph.
Check that the API key can read the account's data and that HARNESS_BASE_URL points at the right Harness instance. A 404 on the query service path means the gateway for that instance does not route /query-service/, or the query service is not enabled for the account.
Stop and report the last error to the user. Do not drop filters or change aggregates to make the query pass.
Re-run Step 1 and Step 2. Types and fields differ between accounts, and sibling entities use different field names.
reference.md (opens in a new tab)references/analysis-workflow.md (opens in a new tab)references/entity-reference/ci.md (opens in a new tab)references/patterns/batch.md (opens in a new tab)references/patterns/bottleneck-analysis.md (opens in a new tab)references/patterns/build-time-analysis.md (opens in a new tab)references/patterns/failure-diagnosis.md (opens in a new tab)references/patterns/flakiness.md (opens in a new tab)references/patterns/intermittent-vs-consistent.md (opens in a new tab)references/patterns/lint-first.md (opens in a new tab)references/patterns/retry-signals.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub harness/harness-ai --plugin harness73 skills in this plugin
/ai-operationsConfigure Harness AI-powered operations (AIDA) via MCP. Set up predictive failure analysis with ML models for memory leaks, disk exhaustion, connection pool saturation, and latency degradation. Configure intelligent alert correlation and noise reduction to reduce alert volume. Use when asked to set up predictive failure analysis, configure AI-powered alerting, reduce alert noise, or enable ML-based anomaly detection. Do NOT use for pipeline debugging (use debug-pipeline instead) or SLO management (use manage-slos instead). Trigger phrases: AIDA, predictive failure, alert correlation, noise reduction, anomaly detection, AI ops, predictive analysis, alert fatigue, ML alerting, intelligent alerting./analyze-costsAnalyze cloud costs, find optimization opportunities, and track anomalies using Harness CCM via MCP. Use when user says "cloud costs", "analyze costs", "cost optimization", "reduce spending", "cost report", or asks about cloud bills./approve-exemptApprove pending Harness STO security exemptions (waivers) at their current scope or elevate them to Project, Org, or Account scope. Users say "approve" for both in-scope approval and higher-scope elevation — do not require the word "promote". Supports approving one exemption or a mixed list where each row has a different approval scope. Default workflow lists pending exemptions in chat (paginated preview) so the user picks by row number — no copying from the Harness UI. Use when a user wants to approve, sign off on, or clear pending exemptions, waive approvals, org-wide approval, or account-wide approval. Trigger phrases: approve exempt, approve exemption, approve waiver, sign off exemption, clear pending exemption, approve for org, approve for account, org-wide approval, account-wide approval, pending exemptions.Other plugins' skills for the same job