Skip to content

Commit 1254064

Browse files
VedranZoricicclaude
andcommitted
Improve skill based on skill-creator review
- Make description pushier for better trigger accuracy (catches PR URLs, "update the spec", "document API change", etc.) - Remove redundant "When to Activate" section (triggering is from description) - Slim SKILL.md from 313 to 205 lines by moving inline YAML templates to reference files and using conditional pointers instead - Add clear "read X when doing Y" guidance for reference files - Condense endpoint/schema checklists into scannable summaries Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b94bf0e commit 1254064

1 file changed

Lines changed: 21 additions & 128 deletions

File tree

  • .claude/skills/generate-openapi-from-pr

.claude/skills/generate-openapi-from-pr/SKILL.md

Lines changed: 21 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
---
22
name: generate-openapi-from-pr
3-
description: Generate OpenAPI spec changes from an intercom monolith PR. Use when a user provides an intercom/intercom PR URL or number and wants to create the corresponding OpenAPI documentation changes in this repo.
3+
description: >
4+
Generate OpenAPI spec changes from an intercom monolith PR. Use this skill whenever a user
5+
provides an intercom/intercom PR URL or number, asks to generate or update OpenAPI docs,
6+
update the spec, document an API change, or mentions shipping API documentation from a PR.
7+
Also trigger when the user pastes a github.com/intercom/intercom/pull/ URL even without
8+
explicit instructions — they almost certainly want spec changes generated. This is the
9+
primary workflow for this repository.
410
511
metadata:
612
author: team-data-foundations
@@ -15,11 +21,6 @@ allowed-tools: Task, Read, Glob, Grep, Write, Edit, Bash, AskUserQuestion
1521

1622
This skill takes an intercom monolith PR (from `intercom/intercom`) and generates the corresponding OpenAPI spec changes in this repo (`Intercom-OpenAPI`).
1723

18-
## When to Activate
19-
20-
- User provides an `intercom/intercom` PR URL or number
21-
- User asks to "generate docs from PR", "create OpenAPI from PR", "document this API change"
22-
2324
## Workflow
2425

2526
### Step 1: Parse Input
@@ -129,136 +130,28 @@ Read the target spec file(s) to understand:
129130

130131
### Step 6: Generate OpenAPI Changes
131132

132-
Use the patterns from the companion guide files:
133-
- **[./ruby-to-openapi-mapping.md](./ruby-to-openapi-mapping.md)** — Ruby pattern → OpenAPI mapping rules
134-
- **[./openapi-patterns.md](./openapi-patterns.md)** — Concrete YAML templates
135-
- **[./version-propagation.md](./version-propagation.md)** — Cross-version propagation rules
136-
137-
#### Adding a new field to an existing schema (most common change)
138-
139-
This is the most frequent PR type. You must update TWO places in the spec:
140-
141-
1. **Schema property** — add the new field to `components/schemas/<schema_name>/properties`
142-
2. **Inline response examples** — search for ALL endpoints that return this schema and update their inline example `value` objects to include the new field
143-
144-
Example from a real PR (adding `previous_ticket_state_id` to ticket):
145-
```yaml
146-
# 1. In components/schemas/ticket/properties — add the field:
147-
previous_ticket_state_id:
148-
type: string
149-
nullable: true
150-
description: The ID of the previous ticket state.
151-
example: '7493'
152-
153-
# 2. In EVERY endpoint response example that returns a ticket — add the value:
154-
examples:
155-
Successful response:
156-
value:
157-
type: ticket
158-
id: '494'
159-
# ... existing fields ...
160-
previous_ticket_state_id: '7490' # ADD THIS
161-
```
133+
Read the appropriate reference file based on what the PR changes:
162134

163-
**To find all examples that need updating**, search the spec file for the schema name:
135+
- **Adding/modifying fields or schemas?** → Read [./ruby-to-openapi-mapping.md](./ruby-to-openapi-mapping.md) for how Ruby presenter attributes map to OpenAPI types
136+
- **Adding new endpoints?** → Read [./openapi-patterns.md](./openapi-patterns.md) for concrete YAML templates (GET, POST, PUT, DELETE, search)
137+
- **Updating multiple versions?** → Read [./version-propagation.md](./version-propagation.md) for the decision tree on which files to update
138+
139+
#### The two most important rules
140+
141+
**Rule 1: Field additions require updates in TWO places.** When adding a field to a schema, you must update both the schema definition in `components/schemas` AND every inline response example that returns that schema. Find all affected examples with:
164142
```bash
165-
grep -n 'schemas/ticket' descriptions/0/api.intercom.io.yaml
166-
```
167-
Then check each endpoint that references that schema and update its inline examples.
168-
169-
#### Required elements for every new endpoint:
170-
171-
1. **`summary`** — short description used as page title in docs (required)
172-
173-
2. **`description`** — longer explanation of what the endpoint does
174-
175-
3. **`Intercom-Version` header parameter** — always reference the schema:
176-
```yaml
177-
parameters:
178-
- name: Intercom-Version
179-
in: header
180-
schema:
181-
"$ref": "#/components/schemas/intercom_version"
182-
```
183-
184-
4. **`tags`** — group name matching existing tags or new tag for new resource
185-
186-
5. **`operationId`** — unique, camelCase identifier (e.g., `listTags`, `createContact`, `retrieveTicket`)
187-
188-
6. **Response with inline examples + schema ref**:
189-
```yaml
190-
responses:
191-
'200':
192-
description: Successful response
193-
content:
194-
application/json:
195-
examples:
196-
Successful response:
197-
value:
198-
type: resource
199-
id: '123'
200-
schema:
201-
"$ref": "#/components/schemas/resource_schema"
202-
```
203-
204-
7. **Standard error responses** — at minimum `401 Unauthorized`:
205-
```yaml
206-
'401':
207-
description: Unauthorized
208-
content:
209-
application/json:
210-
examples:
211-
Unauthorized:
212-
value:
213-
type: error.list
214-
request_id: <uuid>
215-
errors:
216-
- code: unauthorized
217-
message: Access Token Invalid
218-
schema:
219-
"$ref": "#/components/schemas/error"
220-
```
221-
222-
8. **Request body** (for POST/PUT) with schema and examples
223-
224-
#### Required elements for new schemas:
225-
226-
1. **`title`** — Title Case
227-
2. **`type: object`**
228-
3. **`x-tags`** — tag group linkage (must match a top-level tag name)
229-
4. **`description`**
230-
5. **`properties`** — each with `type`, `description`, `example`
231-
6. **`nullable: true`** — on fields that can be null
232-
7. **Timestamps** — `type: integer` + `format: date-time`
233-
234-
#### Top-level `tags` section (for new resources)
235-
236-
If adding a completely new API resource (not just new endpoints on an existing resource), you MUST add a tag entry to the **top-level `tags` array** at the bottom of the spec file (after `security`):
237-
238-
```yaml
239-
tags:
240-
# ... existing tags ...
241-
- name: Your Resource
242-
description: Everything about your Resource
143+
grep -n 'schemas/<schema_name>' descriptions/0/api.intercom.io.yaml
243144
```
244145

245-
This tag name must match:
246-
- The `tags` array on each endpoint (e.g., `tags: [Your Resource]`)
247-
- The `x-tags` on related schemas (e.g., `x-tags: [Your Resource]`)
146+
**Rule 2: New resources need a top-level tag.** If adding an entirely new API resource, add an entry to the `tags` array at the bottom of the spec (alphabetical order). The tag name must match the `tags` on endpoints and `x-tags` on schemas. See existing tags in [./openapi-patterns.md](./openapi-patterns.md) under "Top-Level Tags".
248147

249-
Existing top-level tags include: Admins, AI Content, Articles, Away Status Reasons, Brands, Calls, Companies, Contacts, Conversations, Custom Channel Events, Custom Object Instances, Data Attributes, Data Events, Data Export, Emails, Help Center, Internal Articles, Jobs, Macros, Messages, News, Notes, Segments, Subscription Types, Switch, Tags, Teams, Ticket States, Ticket Type Attributes, Ticket Types, Tickets, Visitors, Workflows.
148+
#### Quick checklist for new endpoints
250149

251-
#### Reusable `components/responses` (optional)
150+
Every endpoint needs: `summary`, `description`, `operationId` (unique, camelCase), `tags`, `Intercom-Version` header parameter (`"$ref": "#/components/schemas/intercom_version"`), response with inline examples + schema `$ref`, and at minimum a `401 Unauthorized` error response. POST/PUT endpoints also need a `requestBody` with schema and examples. See [./openapi-patterns.md](./openapi-patterns.md) for complete templates.
252151

253-
The spec defines reusable error responses in `components/responses`:
254-
- `Unauthorized` — 401 with access token invalid
255-
- `TypeNotFound` — 404 for custom object types
256-
- `ObjectNotFound` — 404 for objects/custom objects/integrations
257-
- `ValidationError` — validation errors
258-
- `BadRequest` — bad request errors
259-
- `CustomChannelNotificationSuccess` — custom channel success
152+
#### Quick checklist for new schemas
260153

261-
You can reference these with `"$ref": "#/components/responses/Unauthorized"` instead of inlining the error response, but most existing endpoints inline their errors. **Match the style of nearby endpoints** in the same resource group.
154+
Every schema needs: `title` (Title Case), `type: object`, `x-tags`, `description`, and `properties` where each property has `type`, `description`, and `example`. Mark nullable fields explicitly with `nullable: true`. Timestamps use `type: integer` + `format: date-time`.
262155

263156
### Step 7: Apply Changes
264157

0 commit comments

Comments
 (0)