/headless-cloud-security:sysdig-sysqlfrom headless-cloud-security
Writes, debugs, and explains SysQL graph queries against the Sysdig Secure security datastore. Validates entities and fields against the live schema before running.
Ships in headless-cloud-security. 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.
Before doing any other work for this skill, follow references/first-run-notice.md exactly.
This skill describes steps by capability, not by tool name: ask a structured question, get explicit confirmation, write a file, run a command. Follow references/agent-capabilities.md for how to do each one with your agent's tools, and what to do when a capability is missing — including when nobody can answer a question.
This skill's output is SysQL query results (tables in chat), not a presentation document. If you're ever asked to turn results into a custom report or document, keep it on-brand per references/on-brand-output.md (or hand off to the sysdig-report skill, if it's installed) — opt-in guidance, never a requirement.
SysQL is a Sysdig proprietary, graph query language. It models cloud and container security data as a graph of entities (resources, vulnerabilities, controls, identities, runtime events) connected by relationships (AFFECTED_BY, HAS_INSTALLED, IN, VIOLATES, …). Translate the user's natural-language request into a precise query, validate its entities and fields against the live schema, show the query, run it, and present the result.
Refer to references/sysql_reference.md for the complete language reference.
What I'll do:
Vulnerability.fixAvailableAt → the real fixDate).generate_sysql MCP tool if I can't build a valid query, then show you that query with its results like any other.What I won't do:
🔒 Golden rule — show before you run
You may not call
run_sysqlunless its exact query is already printed in a fenced ```sql block in your reply, immediately above that call. Every query, no exceptions — the main query and every count / existence / diagnostic check. If you state any result — a number, "0 rows", "no GCP data", "there are 18 EC2s", "0 overlap" — the query that produced it must appear right above it. A finding without its query is a bug. (You'd be most tempted to skip this for quick diagnostic counts — don't.)
Run the preflight in references/auth-preflight.md and follow it exactly — the MCP server must be reachable for run_sysql/generate_sysql. If it says abort, abort. If a later tool call fails, use the diagnostic checklist in references/mcp-setup.md.
Step 2 (live-schema validation) is the primary correctness check. It uses the MCP schema tools (list_sysql_entities to discover, get_sysql_entity to inspect one entity), which share the same MCP authentication as run_sysql — so no extra credentials are needed: if the server is reachable for queries, it's reachable for the schema. If a schema tool call fails, follow step 2's fallback.
Work out the query shape: which entities and relationships to use. Discover them live via MCP — list_sysql_entities for the entity list, then get_sysql_entity for the fields + relationships of each entity you'll use. Use the language syntax in references/sysql_reference.md. Reuse data already in the query before traversing (e.g. RuntimeEvent.hostName instead of joining Host); always filter zones by numeric zone ID. Self-check it answers the question (e.g. "critical vulns" needs severity = 'Critical', not a bare MATCH Vulnerability). Add a sensible LIMIT (default 50, max 1000).
This draft is scratch — do not print it. Never guess field or relationship names — they come from the MCP schema tools (step 2); the draft only settles which entities/relationships you'll use.
Apply these filter conventions as you write:
c.name =~ '(?i).*nginx.*', not =.r.type =~ '(?i).*s3.*'.EC2Instance HAS_ACCESS S3Bucket, don't hand-expand it through IAMInstanceProfile → IAMRole → … that the question never mentioned, just to keep one MATCH. A single linear MATCH is fine for a direct chain; to branch from the same node, or to avoid routing through irrelevant entities, use multiple MATCH clauses that repeat the shared alias, each with an explicit relationship (MATCH k AFFECTED_BY Vulnerability AS v / MATCH k GENERATES RuntimeEvent AS e). No comma multi-path (MATCH a REL b, a REL c) and no Cypher-style WITH <var> — SysQL's only WITH is the subquery stage WITH … FROM (…) below.Vulnerability, Package, Container, Image, RuntimeEvent, CloudResource): never ORDER BY … LIMIT a big join in the main part — it sorts the whole join first. Sort and limit the entity you rank by inside a WITH … FROM (…) stage, with its own filters, then traverse from the survivors: WITH v FROM (MATCH Vulnerability AS v WHERE v.severity = 'Critical' ORDER BY v.cvssScore DESC LIMIT 50) MATCH KubeWorkload AS k AFFECTED_BY v RETURN …. A stage LIMIT counts entities ("top 20 workloads with their vulns"), the outer LIMIT counts rows. The main part must still start with MATCH; an aggregate alias projected by the stage must appear in RETURN/WHERE to be sortable; the stage's ORDER BY can't use an aggregate alias. Rules and examples: references/sysql_reference.md.field =~ '^(?!value).*' (SysQL has no !~).WHERE entity.publicIPs != NULL (or privateIPs).Critical, High, Medium, Low, Info; regions are canonical cloud regions (us1/virginia → us-east-1, oregon → us-west-2, frankfurt → eu-central-1, …). Use single quotes for string literals.The live schema — not the static docs — decides which fields and relationships are real. For every entity in the draft, fetch its live definition and set the query's fields/relationships from it:
get_sysql_entity (entity_name: <EntityName>) once — reuse the result within the session, don't re-fetch. The response is authoritative: its fields are the only valid field names, and its relationships (each with a name + target entity) the only valid traversals. (Use list_sysql_entities first if you're unsure an entity exists.)entity.field and every relationship in the query a name that actually appears in these responses. Replace any guess that isn't there — e.g. Container has imageReference, not image/imageName; Vulnerability has fixDate, not fixAvailableAt. For a multi-hop path, fetch each hop's entity and chain through its real relationships.The query is final only once every field and relationship is confirmed against these live responses.
Fallback (degraded). If the schema tools are unavailable (server unreachable or erroring), draft from your own knowledge of the data model and let the run_sysql 422 be the validator; reach for generate_sysql sooner. This is the only situation where a query may be shown without prior live validation.
Before every run_sysql call, print the query you're about to run in a fenced ```sql block — the user watches each query in real time, in order, right before it executes. Then call run_sysql. Show only a validated query — one whose entities, fields and relationships you've confirmed in step 2; never show a draft, a guess, or an unvalidated query.
Run as many queries as the analysis needs — discovery, the main query, diagnostics when results are empty ("are there any exposed EC2s at all?"), drill-downs — and show each one in its own block before its call.
422 parse error (rare, since step 2 validated it) → fix it and show only the corrected, valid query for the re-run; don't leave an invalid query standing. Common causes: SysQL is not Cypher, so WITH <var> carried into a following MATCH is invalid — use repeated MATCH with a shared alias; a WITH … FROM (…) stage followed by RETURN with no MATCH, DISTINCT/aggregates without an alias in the stage list, or a stage ORDER BY on an aggregate alias (see references/sysql_reference.md). After 2 failed fixes, fall back to generate_sysql.Every query you display is valid and validated. Never run a query the user hasn't just seen, and never state a finding (a count, "there are 18…", "0 overlap") without the query shown right above it. This holds for the first question and every follow-up.
The queries are already shown inline (step 3) — don't re-list them. Close with the synthesised answer: a one-line headline, then the results as a table (lead with the most important columns — severity, name, affected resource). When results are empty or partial, add a short explanation of what the data does and doesn't cover (a small table or bullets), grounded in the queries already shown above.
Limits and truncation. If no LIMIT was set, the server default is 50; max is 1000. When the row count equals the LIMIT, the result is likely truncated — say so:
Showing 50 of (likely more) results. Increase
LIMIT(max 1000) or add filters to narrow down.
Suggest 3 in-scope follow-up questions to help the user dig deeper. When results are available, fill placeholders (e.g. <resource-name>) with values from the question or the results; when none are available yet, show placeholders as inline code. Keep them coherent with the question and within Scope.
When the user picks a follow-up (or asks anything new), restart from step 1 — validate against the live schema, show each validated query right before running it, and close with the analysis. Every time.
The live SysQL schema is fetched through the MCP server (same authentication as run_sysql — no extra credentials):
list_sysql_entities (optional show_hidden) — the list of queryable entities, for live discovery.get_sysql_entity (entity_name, optional show_hidden) — one entity's real fields + relationships. The validation workhorse (step 2): call it for each entity you'll use.User: "vulnerabilities with known exploits, with the date a fix became available"
Draft → validate with get_sysql_entity (entity_name: Vulnerability) — the response has hasExploit, hasFix, fixDate, cvssScore but no fixAvailableAt, so use fixDate → show the query → run via run_sysql:
MATCH Image AS i HAS_INSTALLED Package AS p AFFECTED_BY Vulnerability AS v
WHERE v.hasExploit = true AND v.hasFix = true
RETURN i.imageReference, v.name, v.severity, v.fixDate
ORDER BY v.severity DESC
LIMIT 50;
Then the results table, then 3 follow-ups.
User: "list the container images running in the
prod-clusterk8s cluster"
Container's fields aren't known up front, so don't guess. Call get_sysql_entity for KubeWorkload (shows a HAS/RUNS → Container relationship) and for Container (shows imageReference, not image/imageName). Build and show the validated query, then run:
MATCH KubeWorkload AS k HAS Container AS c
WHERE k.clusterName =~ '(?i).*prod-cluster.*'
RETURN DISTINCT c.imageReference
LIMIT 50;
User: "Which workloads violate the S3 control?"
The control filter is a case-insensitive substring match, so no lookup is needed. Only if several real controls plausibly match the intent do you ask a structured question before running.
# Workloads in production affected by critical vulns
MATCH KubeWorkload AS k AFFECTED_BY Vulnerability AS v
WHERE v.severity = 'Critical' AND k.namespaceName = 'production'
RETURN k.name, k.clusterName, v.name, v.cvssScore;
# Branch from the same node: workloads with a critical vuln AND a runtime event
MATCH KubeWorkload AS k AFFECTED_BY Vulnerability AS v WHERE v.severity = 'Critical'
MATCH k GENERATES RuntimeEvent AS e
RETURN DISTINCT k.name, k.namespaceName;
# Top-N on a numerous entity: sort + limit in a WITH stage, then join (not ORDER BY on the whole join)
WITH v FROM (MATCH Vulnerability AS v WHERE v.severity = 'Critical' AND v.hasExploit = true ORDER BY v.cvssScore DESC LIMIT 50)
MATCH KubeWorkload AS k AFFECTED_BY v
RETURN v.name, v.cvssScore, k.name, k.namespaceName ORDER BY v.cvssScore DESC;
# Rank by count with extra data joined after aggregating; WHERE on the alias acts as HAVING
WITH k, count(v) AS c FROM (MATCH KubeWorkload AS k AFFECTED_BY Vulnerability AS v WHERE v.severity = 'Critical')
MATCH k IN Zone AS z WHERE c > 10
RETURN k.name, z.name, c ORDER BY c DESC LIMIT 20;
Report problems with the What happened → Why → What to do next pattern.
run_sysql/generate_sysql tools missing. The MCP server isn't reachable → follow the diagnostic checklist in references/mcp-setup.md; report only the specific failing step.references/mcp-setup.md; don't retry the denied call.list_sysql_entities / get_sysql_entity) errors or the server is unreachable → draft from your own knowledge and let the run_sysql execution surface a 422 parse error, then fix from that message.422. Handled by step 3 (read the parse error → fix → re-validate → re-run, max 2, then generate_sysql). Surface to the user only if the fallback also fails — don't pretend it succeeded.RETURN DISTINCT Entity.field query, loosen the filter, or check the zone/account scope. Offer to re-run with the change.LIMIT. Communicate the likely truncation; offer to raise LIMIT (max 1000), paginate with OFFSET, or add filters. If the query sorts a join over a numerous entity, offer to move the sort and LIMIT into a WITH … FROM (…) stage instead of raising LIMIT.You can analyze the CSPM areas listed in references/cspm_questions.md. If a question falls outside, apologize and suggest a possible in-scope alternative.
We talk about risks for misconfigurations or risky conditions (e.g. exposed workloads with critical vulnerabilities, publicly exposed S3 buckets, resources with failed controls) and about findings when a risk is actually present (e.g. critical vulnerabilities, publicly exposed resources, vulnerabilities with an exploit, failed controls).
references/sysql_reference.md — complete language reference (syntax). Entities, fields and relationships come from the live MCP schema tools (list_sysql_entities / get_sysql_entity), not from a static file.references/cspm_questions.md — catalog of supported CSPM questions and scope.references/mcp-setup.md — register the Sysdig MCP server and the diagnostic checklist.references/auth-preflight.md — pre-flight to run before any MCP call.references/agent-capabilities.md (opens in a new tab)references/auth-preflight.md (opens in a new tab)references/cspm_questions.md (opens in a new tab)references/first-run-notice.md (opens in a new tab)references/mcp-setup.md (opens in a new tab)references/on-brand-output.md (opens in a new tab)references/sysql_reference.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sysdig, sysql, security-queries, graph-query, cloud-security
npx claudepluginhub sysdig/skills --plugin headless-cloud-security8 skills in this plugin
/sysdig-account-setupBaseline account setup for Sysdig Secure after a tenant is connected. Guided, interactive, modular setup via the Sysdig MCP server: (1) access baseline — teams, users, and roles; (2) vulnerability management policy baseline — Pipeline vs runtime, one policy or split; (3) compliance standards — assign posture policies (CIS, PCI, NIST, …) to zones; (4) runtime threat-detection — enable/disable the recommended managed detection policies. Reviews current state, proposes a structure, and applies changes idempotently with explicit confirmation before anything that mutates the tenant. Use right after onboarding to leave an account usable out of the box. Fine-grained policy tuning is out of scope.
/sysdig-investigateInvestigate and prioritize vulnerable images in a Sysdig-monitored environment via two flows, routed from the user's goal. Plans flow — plan-driven prioritization: pick an admin-configured Plan (or explore ranked jobs under an ad-hoc scope and measure) and walk the prioritized remediation jobs one at a time. Findings flow — ad-hoc findings analysis: filter, regroup, sort, and page vulnerability findings the way the Vulnerability Management UI table does. Hands any chosen image off to /sysdig-remediate, which owns tickets, PRs, job tracking, and job closing. Triggers on: "investigate", "what should I fix", "what should I fix first", "show me my vulnerable images", "prioritize vulnerabilities", "which images are affected by CVE-...", "show me all Critical CVEs in production", "/sysdig-investigate". Not for opening PRs, applying fixes, or creating/updating tickets — use /sysdig-remediate for all of those.
/sysdig-onboardingInteractive onboarding assistant for Sysdig Secure. Guides users through connecting AWS, GCP and Azure cloud accounts, Kubernetes clusters (including Windows nodes), and Linux hosts to Sysdig, plus serverless workload scanning (AWS ECS/Fargate, AWS Lambda, GCP Cloud Run). Presents security capabilities in plain language instead of jargon. Supports guided (interview) and autonomous (all-at-once) modes. Generates Terraform configurations for cloud accounts and Helm values for Kubernetes, validates prerequisites, deploys, and verifies connectivity.
/sysdig-postureAuthor Sysdig Secure Posture custom controls (Rego) and custom policies, and emit Terraform via the Sysdig provider. Use when the user wants to "write a posture rule," "create a custom CSPM control," "fail my policy when an S3 bucket is unencrypted," or "group these CIS controls into a custom policy." Never writes to Sysdig directly — all writes go through Terraform on user approval. Not for: zone management, built-in Sysdig controls, runtime threat detection, vulnerable-image triage or remediation, or onboarding cloud accounts./sysdig-remediateRemediate one specific vulnerable container image and deliver the fix as a PR/MR, a tracking ticket, or both — this skill is the sole ticket creator in the Sysdig vulnerability workflow. Deduplicates existing work (job artifacts, Sysdig-created Jira tickets, external tickets and PRs) read-only, fetches Critical/High CVEs from Sysdig, resolves a safe fix version via chain analysis, opens a PR/MR (GitHub/GitLab) or emits a local patch, creates or updates the Jira ticket, records artifacts on the remediation job, and closes the job once the work is filed. Triggers: "fix the nginx image", "patch CVE-2024-1234 in api-server", "remediate quay.io/org/app:tag", "create a ticket for CVE-2024-9999", "file a Jira ticket for this image", "/sysdig-remediate <image>". Not for: discovery, prioritization, or slicing findings — use /sysdig-investigate.
/sysdig-runtime-investigateUse this skill when investigating a runtime threat detected by Sysdig end-to-end. Surfaces the highest-priority threat, scores vulnerability vs runtime correlations on a 1-5 confidence scale, deep-dives into network blast radius or suspicious-binary VirusTotal lookups depending on the event class, reconstructs the affected workload's activity audit trail (commands, connections, file accesses) as a timeline around the detection, and hands the case off to Jira or PagerDuty. Triggers on: "investigate runtime threat", "what is this Falco alert", "triage this SOC alert", "analyze runtime incident". Not for vulnerability prioritization (use `sysdig-investigate`) or remediation (use `sysdig-remediate`).
Other plugins' skills for the same job