---
name: get-cluster-cr
description: |
  Fetch curated Dedicated cluster resources (cluster_cr, optional
  scale_status_cm) by cluster_id via Ops cluster-resources API. Use for
  Cluster CR or scale-status ConfigMap lookup. Do not use for arbitrary
  K8s Kind/GVK, Pods, APPBox, CP/DP list, or label/field filters — use
  get-k8s-resource instead.
---

# Action Type

`read-only`

- This subskill only queries backend data.
- It must not trigger any mutable API.

# Prerequisite

**You MUST read `mechanisms/extend-devops-api.md` (located in this skill's
root directory) in full before executing any action in this subskill.**

This mechanism document defines:
- How to resolve the `devops_http.sh` provider script path
- Path resolution failure handling (never glob or search)
- Token pre-check requirements
- Required argument workarounds

Do not proceed without reading it. Do not guess or search for provider file
paths — the mechanism document contains the exact resolution formula.

# Boundary

- Use **this** subskill for curated `cluster_cr` / `scale_status_cm` by `cluster_id`.
- Use **`get-k8s-resource`** for arbitrary Kind, CP/DP, selectors, detail/events.

# Available Actions

## Get Cluster CR

Query cluster resources for a target cluster and focus on the `cluster_cr` item.

API Path: `/clusters/{cluster_id}/cluster-resources`.

Method: `GET`.

### Interface Details

- Required input:
  - `cluster_id` (string): target cluster ID.
- Optional input:
  - `env` (string): one of `prod`, `staging`, `dev`. Default: `prod`.
- `devops_http.sh` path:
  - `--path /clusters/{cluster_id}/cluster-resources`
- Known resources (from cluster-server providers):
  - `cluster_cr` — Cluster CR (always present when the API succeeds).
  - `scale_status_cm` — Scale Status ConfigMap (only when the scale-status
    feature is enabled on the cluster).
- Expected response focus:
  - Keep full response JSON payload, especially `.resources[]`.
  - Prefer the `cluster_cr` item; note `scale_status_cm` when present.
  - If `cluster_cr` is absent, explicitly report "not found".
- Verification points:
  - Top-level `resources` array exists.
  - Resource items include `key`, `display_name`, `description`, `type`, `content`.
- Output formatting:
  - **Do not** parse or unescape the `content` field manually.
  - Pipe the `devops_http.sh` JSON output through the formatting script
    `scripts/format-cluster-resources.sh` located in this subskill's directory
    (`get-cluster-cr/scripts`).
  - The script sorts `cluster_cr` first, titles each item with `display_name`,
    prints description + markdown-fenced `content`, and warns if `cluster_cr`
    is missing.
  - Example invocation (pipe composition):

    ```bash
    bash <provider-skill-root>/scripts/devops_http.sh \
      --env dev \
      --path /clusters/{cluster_id}/cluster-resources \
      --header "X-Request-ID: cr-lookup" \
    | bash <this-subskill-root>/scripts/format-cluster-resources.sh
    ```

    Where `<this-subskill-root>` resolves to
    `<toolkit-skill-root>/get-cluster-cr`.
  - Present the script's stdout directly to the user without further LLM
    post-processing of `content` bodies.
