{"name":"block-kit","url":"https://github.com/slackapi/slack-skills-plugin/tree/main/skills/block-kit","install":"npx skills add slackapi/slack-skills-plugin --skill block-kit","sdk":"slack","key":"slack/block-kit","description":"Help developers build and validate Block Kit layouts for Slack messages, modals, and Home tabs. Provides authoritative block references and validates with the blocks.validate API. Use this skill whenever the developer wants to compose Slack message layouts, build modals/forms/dialogs, design Home tab interfaces, create interactive messages with buttons or menus, modify existing Block Kit JSON, or asks about any Slack UI component (sections, actions, inputs, headers, alerts, tables, carousels). Also trigger when they mention \"blocks\", \"Block Kit Builder\", or paste JSON containing block structures like `\"type\": \"section\"`.","hasContent":true,"content":"---\nname: block-kit\ndescription: 'Help developers build and validate Block Kit layouts for Slack messages, modals, and Home tabs. Provides authoritative block references and validates with the blocks.validate API. Use this skill whenever the developer wants to compose Slack message layouts, build modals/forms/dialogs, design Home tab interfaces, create interactive messages with buttons or menus, modify existing Block Kit JSON, or asks about any Slack UI component (sections, actions, inputs, headers, alerts, tables, carousels). Also trigger when they mention \"blocks\", \"Block Kit Builder\", or paste JSON containing block structures like `\"type\": \"section\"`.'\nargument-hint: \"[message | modal | home-tab]\"\n---\n\n# Block Kit\n\nHelp the developer build a rich Block Kit layout. If `$0` is provided, it specifies the target surface (`message`, `modal`, or `home-tab`).\n\nThis skill walks through surface selection, layout planning, JSON generation, and validation. Block types, elements, and fields come from the live docs (see **Source of Truth** below) — discover them and read each component's schema there, never from memory.\n\n> **Common Block Kit mistakes (and why):** A few errors recur often enough to flag up front. Most others are caught by `blocks.validate` in Step 5, so lean on validation rather than memorizing rules.\n>\n> - **`\"type\": \"text\"` is not a thing.** Text is a composition object: `{ \"type\": \"plain_text\", \"text\": \"...\" }` or `{ \"type\": \"mrkdwn\", \"text\": \"...\" }`.\n> - **`markdown` is a _block_ type, not a text type.** A `markdown` block holds standard markdown; text objects inside other blocks use `mrkdwn` (see **mrkdwn vs. the `markdown` block** in Step 4). Slack's `mrkdwn` is `*bold*` / `_italic_` / `~strike~`, not `**bold**`.\n> - **Messages need a top-level `text` fallback.** `blocks.validate` won't flag a missing one, but notifications and screen readers display it instead of the blocks — so summarize what the layout conveys rather than leaving it empty.\n\n---\n\n## Source of Truth: the Live Docs\n\nEvery block, element, and composition object is documented on `docs.slack.dev`. Append `.md` to any reference URL to fetch it as markdown with WebFetch (no auth required).\n\n- **Master index**: the authoritative list of every block, block element, and composition object, each linking to its own page: `https://docs.slack.dev/reference/block-kit.md`. WebFetch it to confirm a type exists and to get the link to its page.\n- **Per-component pages** carry the full field schema (a fields table with required/optional flags and constraints, plus JSON examples):\n  - Blocks: `https://docs.slack.dev/reference/block-kit/blocks/<slug>-block.md`\n  - Block elements: `https://docs.slack.dev/reference/block-kit/block-elements/<slug>-element.md`\n  - Composition objects: `https://docs.slack.dev/reference/block-kit/composition-objects/<slug>.md`\n- **The slug is not always the type name.** For example `datepicker` maps to `date-picker-element.md`, and every `*_select` menu (`static_select`, `users_select`, `multi_channels_select`, and so on) is documented on `select-menu-element.md`. When unsure of a slug, follow the link from the master index rather than building the URL by hand.\n- **Surface payload structure** lives in the surface guides: messages at `https://docs.slack.dev/messaging/formatting-message-text.md`, modals at `https://docs.slack.dev/surfaces/modals.md`, and Home tabs at `https://docs.slack.dev/surfaces/app-home.md`.\n\nNever use a block type, element, or field you have not seen on a live page.\n\n---\n\n## Fast Path (for clear, specific requests)\n\nIf the developer's request is specific enough to determine both the target surface and the desired layout, collapse Steps 1-4 into a single pass:\n\n1. Determine the surface from `$0` or context\n2. Fetch only the doc pages for the blocks and elements mentioned\n3. Generate the JSON directly\n4. Proceed to Step 5 (validation)\n\n**Fast-path indicators** (skip the full workflow):\n\n- Developer provides existing JSON to modify → use Modification Mode instead\n- Developer names specific block types: \"add an actions block with two buttons\"\n- Developer describes a well-known pattern: \"approval message\", \"feedback form\", \"settings modal\"\n- Developer provides a complete description in one message with enough detail to build\n\n**Full-workflow indicators** (use Steps 1-7):\n\n- Vague requests: \"make something cool\", \"build a dashboard\"\n- Exploratory: \"what can Block Kit do?\", \"show me my options\"\n- Complex layouts: 10+ blocks, nested modals, conditional logic\n- Developer asks for help deciding what to build\n\n---\n\n## Modification Mode\n\nIf the developer provides existing Block Kit JSON (pasted inline, in a file, or referenced from code), enter Modification Mode instead of the full creation workflow:\n\n1. **Parse the existing structure:**\n   - List each block by index, type, and a short description of its content\n   - Infer the surface: `\"type\": \"modal\"` = modal, `\"type\": \"home\"` = home tab, bare `blocks` array = message\n\n2. **Ask what changes they want:**\n   - Add blocks (where in the sequence?)\n   - Remove blocks (which ones?)\n   - Modify blocks (which block, what change?)\n   - Reorder blocks\n\n3. **Apply changes while preserving:**\n   - All existing `block_id` values (these are referenced in app interaction handlers)\n   - All existing `action_id` values (these map to event listeners)\n   - Existing styles, text content, and structure for unchanged blocks\n\n4. **Validate the modified JSON**: proceed to Step 5 (validation)\n\n**Detection:** If the developer's message contains a JSON array starting with `[{\"type\":` or a view object with `\"blocks\":`, enter Modification Mode automatically. If they say \"edit\", \"update\", \"modify\", or \"change\" in reference to existing blocks, ask them to provide the current JSON.\n\n---\n\n## Step 1: Determine the Target Surface\n\nIf `$0` is provided and matches one of `message`, `modal`, or `home-tab`, use it directly.\n\nOtherwise, ask the developer using AskUserQuestion:\n\n- **Message**: Conversational content posted to a channel or DM. Max 50 blocks.\n- **Modal**: A dialog or form opened by a user action. Max 100 blocks.\n- **Home tab**: A persistent, per-user dashboard in the App Home. Max 100 blocks.\n\nOnce the surface is determined, use the correct payload structure for it:\n\n- **Message**: a `{ \"text\": \"Fallback text\", \"blocks\": [...] }` object posted via `chat.postMessage` (and friends). The `text` field is the notification/accessibility fallback. For message text formatting (mrkdwn, mentions, dates), see `https://docs.slack.dev/messaging/formatting-message-text.md`.\n- **Modal**: a view object (`{ \"type\": \"modal\", \"title\": ..., \"blocks\": [...] }`). For the full view object structure, lifecycle, and the rule that `submit` is required when the view contains any `input` block, see `https://docs.slack.dev/surfaces/modals.md`.\n- **Home tab**: a view object (`{ \"type\": \"home\", \"blocks\": [...] }`) published via `views.publish`. For structure and behavior, see `https://docs.slack.dev/surfaces/app-home.md`.\n\n---\n\n## Step 2: Understand What to Build\n\nAsk the developer to describe what they want their layout to look like or accomplish.\n\nIf they need inspiration, suggest examples — several map directly onto a ready-made template in `references/common-patterns.md` (named in parentheses), which you can start from in Step 3:\n\n- \"A feedback form with a text input and a category selector\" (Simple Form Modal)\n- \"A notification message with an alert banner, description, and Approve/Reject buttons\" (Notification Alert / Approval Message)\n- \"A dashboard home tab with a welcome header, key metrics in fields, and quick-action buttons\" (Dashboard Home Tab)\n- \"A settings modal with dropdowns, checkboxes, and a time picker\" (Settings Modal with Multiple Input Types)\n- \"A table of sprint tasks with status and points\" (Data Table)\n\nGet enough detail to plan the layout before generating any JSON.\n\n---\n\n## Step 3: Plan the Block Layout\n\nBased on the developer's description:\n\n1. **Fetch only what you need** from the live docs:\n   - WebFetch the master index (`https://docs.slack.dev/reference/block-kit.md`) to confirm the block and element types you plan to use exist and to grab links to their pages.\n   - Check `references/common-patterns.md` (the one local reference file) if the request matches a common pattern; start from the template instead of building from scratch.\n   - Defer reading individual component pages until Step 4, when you build each block's fields.\n2. Propose a numbered block outline. For example:\n\n   ```text\n   1. header: \"Weekly Report\"\n   2. section: Summary text with a datepicker accessory\n   3. divider\n   4. section: Status fields (Name, Role, Team)\n   5. actions: \"Approve\" button (primary) and \"Reject\" button (danger)\n   ```\n\n3. Present the outline to the developer and ask for approval or changes before generating JSON.\n\n**Surface constraints to check:**\n\n- Block count limit: 50 for messages, 100 for modals/home tabs\n- Modal-specific: if using `input` blocks, the modal payload must include a `submit` field\n- Table: only one `table` block per message\n- Surface compatibility (whether a block is valid on the chosen surface) and element compatibility (whether an element is allowed inside a given block) are not always spelled out on a component's doc page. Build the layout from the docs, and let `blocks.validate` in Step 5 confirm it. It is the authoritative check.\n\n---\n\n## Step 4: Generate the Block Kit JSON\n\nOnce the layout is approved, build each block from its live doc page, fetching each page's fields table (required vs optional, constraints) and JSON example with WebFetch. The URL patterns are in **Source of Truth** above; the one slug to remember is that every `*_select` menu (`static_select`, `users_select`, `multi_channels_select`, …) lives on `select-menu-element.md`. Fetch pages as you need them and reuse what you have already fetched — don't re-fetch the same page for every block of the same type. Then build the payload block-by-block and wrap it in the surface structure from Step 1.\n\n**Guidelines:**\n\n- Use descriptive `action_id` values (e.g., `\"approve_report_btn\"` not `\"action_1\"`) — they identify the element in your interaction handlers\n- Include `block_id` values where the developer will need them for interaction handling\n- For modals, include `title`, `submit`, `close`, and `callback_id`; for home tabs, the `type: \"home\"` wrapper\n- Use `mrkdwn` text for rich formatting, `plain_text` where required (headers, labels, modal title)\n\n**mrkdwn vs. the `markdown` block:** `section` and `context` blocks format text with Slack's `mrkdwn` (`*bold*`, `_italic_`, `~strike~`, `` `code` ``) — use these for short, interactive layouts. The separate `markdown` block (Messages only) renders _standard_ markdown (`**bold**`, headings, tables, numbered lists) and is meant for AI/LLM-generated or long-form content that already exists in standard markdown. Reach for it when the developer has such content or needs those features in the message body; there is a cumulative 12,000-character limit across all `markdown` blocks in one message.\n\n**Accessibility** is easy to skip and hard to retrofit, so build it in now:\n\n- Give images descriptive `alt_text` (what the image shows, not just \"image\"), and make sure image-heavy layouts also carry the key information as text\n- Summarize the layout in the message's `text` fallback (notifications and screen readers show it instead of the blocks)\n- Use `header` blocks for logical section headings — they convey document structure to assistive tech\n\nPresent the complete payload to the developer in the Step 1 surface structure.\n\n---\n\n## Step 5: Validate with blocks.validate\n\n**Always validate.** `blocks.validate` is a public Web API method, so no auth token is required.\n\nThe authoritative reference for this method (its parameters, auth requirements, and response/error shape) is the live doc. WebFetch it before relying on any detail here: `https://docs.slack.dev/reference/methods/blocks.validate.md`. It documents the accepted parameters (`blocks` for a message's blocks array, `view` for a modal/home-tab view, `message` for a full message payload; send exactly one) and the response shape.\n\n### 5a. Build the validation request\n\nPrefer the Slack CLI when it's available, since it reuses the slack-cli skill's CLI detection and needs no token wrangling. If the CLI isn't installed, fall back to curl. Both call the same public method and return the same response, so Step 5b applies either way.\n\n**Path A: Slack CLI (preferred).**\n\nUse the `slack:slack-cli` skill, **Step 1: Detect the Slack CLI**, to check whether the public CLI is installed and resolve its command (`SLACK_CMD`).\n\nIf the CLI is available, use the `slack:slack-cli` skill, **Step 4: Calling Web API Methods (`slack api`)**, to invoke it. That step covers the `SLACK_CMD api <method> key=value …` syntax. Run `SLACK_CMD api --help` first to confirm the syntax **and the flag that skips authentication**. `blocks.validate` needs no token, so call it without authentication. Don't hard-code that flag from memory; read it from the help output so this stays correct if it's ever renamed. Pass the payload as a positional `key=value` argument: `blocks=<JSON array>` for messages, or `view=<JSON view object>` for modals and home tabs.\n\n**Path B: curl (fallback, when the CLI isn't installed).**\n\nPOST to the endpoint with the **Bash tool**. The API uses form-urlencoded encoding, so pass the JSON directly as the parameter value.\n\n**For messages**, send the `blocks` array as a form-encoded parameter:\n\n```bash\ncurl -s -X POST 'https://slack.com/api/blocks.validate' \\\n  -d 'blocks=[ ... the blocks array ... ]'\n```\n\n**For modals and home tabs**, send the complete view object in the `view` field:\n\n```bash\ncurl -s -X POST 'https://slack.com/api/blocks.validate' \\\n  -d 'view={ \"type\": \"modal\", \"title\": ..., \"blocks\": [...] }'\n```\n\n**For large payloads**, if the JSON is complex or contains special characters, write it to a temp file to avoid shell escaping issues:\n\n```bash\ncurl -s -X POST 'https://slack.com/api/blocks.validate' \\\n  --data-urlencode \"blocks@/tmp/blocks.json\"\n```\n\n### 5b. Handle the response\n\n**Success:**\n\n```json\n{ \"ok\": true }\n```\n\nTell the developer their blocks are valid.\n\n**Failure:**\n\n```json\n{\n  \"ok\": false,\n  \"error\": \"invalid_blocks\",\n  \"errors\": [\n    {\n      \"code\": \"missing_field\",\n      \"message\": \"missing required field: type\",\n      \"field\": \"type\",\n      \"pointer\": \"/0\"\n    }\n  ]\n}\n```\n\nWhen validation fails:\n\n1. Read each error. `pointer` is a JSON pointer to the offending node (e.g., `/0` = first block, `/2/elements/1` = second element of the third block, `/0/text/type` = the `type` field of the first block's text object). `message` describes the problem, and `constraint` (when present) names the rule that failed and its expected values.\n2. Explain the error to the developer in plain language.\n3. Fix the JSON. For the authoritative meaning of an error code and the field requirements behind it, consult the live method doc (`https://docs.slack.dev/reference/methods/blocks.validate.md`) and the relevant block/element/composition-object page you fetched in Steps 3-4.\n4. Re-validate. Repeat until `\"ok\": true`.\n\n### Escape Hatch\n\nIf validation fails 3 times on the same error:\n\n1. Present the raw error and current JSON to the developer\n2. Offer to open the JSON in Block Kit Builder for visual debugging: `https://app.slack.com/block-kit-builder`\n3. Ask if they want to simplify the layout to avoid the constraint\n\n---\n\n## Step 6: Deliver the Final Output\n\nPresent the validated payload, then help the developer put it to use.\n\n### Send it\n\nBuilding the payload is this skill's job; sending it (`chat.postMessage`, `views.open`, `views.publish`, and the token/scope handling around them) belongs to the Web API layer. To call the right method — via the Slack CLI, raw curl, or a Bolt SDK — use the `slack:slack-api` skill, **Step 4: Call the Method (Manage)**, passing this payload as the method's `blocks` argument (messages) or `view` argument (modals and home tabs). That skill matches the argument names to the SDK or HTTP call so we don't duplicate them here.\n\n### Preview it\n\nOffer a Block Kit Builder link so the developer can see a live preview and tweak visually: `https://app.slack.com/block-kit-builder`. Builder needs an object (`{ \"blocks\": [...] }` or a full view object), not a bare array. Suggest this proactively when the developer says something is \"not quite right\" but can't articulate what, when the layout has 10+ blocks, or when iteration isn't converging.\n\n---\n\n## Step 7: Iterate\n\nAsk whether the developer wants to add, modify, remove, or reorder blocks, or build a layout for a different surface. If they want to change the layout you just produced, re-enter **Modification Mode** (it preserves their `block_id`/`action_id` values); for a fresh layout, loop back to Step 3.\n\n---\n\n## Notes\n\n- **Scope:** this skill owns building and validating the Block Kit payload — choosing the surface, composing the JSON from the live docs, and confirming it with `blocks.validate`. Sending it lives in the Web API layer (`slack:slack-api`), and CLI detection/auth in `slack:slack-cli`.\n- **`blocks.validate` needs no auth** — it's a public method, so it works without a token whether you call it via the CLI or curl. Always validate before finalizing (Step 5).\n","contentSource":"https://raw.githubusercontent.com/slackapi/slack-skills-plugin/main/skills/block-kit/SKILL.md","contentFetchedAt":"2026-07-27T08:59:36.536Z"}