version-api
>
Works with
---
name: version-api
description: >
license: MIT
---
# Version API
Implement versioning strategies for Rails APIs.
## Quick Reference
| Concern | File |
|---|---|
| Route namespaces | `config/routes.rb` |
| Header versioning | `app/controllers/concerns/api_versioning.rb` |
| Deprecation headers | `app/controllers/concerns/deprecatable.rb` |
| Compatibility specs | `spec/requests/api/backward_compatibility_spec.rb` |
## HARD-GATE
```text
GENERATED CODE SAFETY:
- NEVER generate code that constantizes or evaluates caller-supplied version strings
(e.g. "V#{params[:version]}".constantize is forbidden — use an explicit allowlist).
- NEVER generate code that passes request headers or paths unsanitized into class
instantiation, eval, or dynamic dispatch.
- Allowlist-only version resolution: generated routing/concern code MUST resolve
version identifiers from a fixed set (V1, V2, ...), not from free-form input.
ALWAYS maintain backward compatibility for at least one major version
NEVER remove endpoints without deprecation period
ALWAYS version in URL path (/api/v1/) or Accept header, never in body
```
## Core Process
1. **Choose strategy** — URL path (`/api/v1/`) for public APIs; Accept header for internal/private APIs. See [strategies.md](./references/strategies.md) for header-based versioning details and trade-offs.
2. **Add route namespace** — Wrap new version resources in a `namespace :v2` block in `config/routes.rb`:
```ruby
namespace :v1 do
resources :users
end
namespace :v2 do
resources :users
end
```
3. **Create controllers** — Inherit from the previous version's controller and override only changed actions:
```ruby
module V2
class UsersController < V1::UsersController
def index
render json: User.all, only: [:id, :name, :email, :phone]
end
end
end
```
See [EXAMPLES.md](./EXAMPLES.md) for additional inheritance patterns.
4. **Apply deprecation** — Include `Deprecatable` in old-version controllers to emit `Sunset` and `Deprecation` response headers automatically via a `before_action`:
```ruby
module V1
class UsersController < ApplicationController
include Deprecatable
# Override sunset_date on the class to set the retirement date:
# def self.sunset_date = Date.new(2025, 6, 1)
end
end
```
5. **Run compatibility specs** — Execute `bundle exec rspec spec/requests/api/backward_compatibility_spec.rb` to confirm no regressions before merging.
6. **Update documentation** — Record the sunset date and migration guide for deprecated endpoints. See [workflow.md](./references/workflow.md) for the full deprecation communication workflow.
## Output Style
When asked to implement API versioning, your output MUST include:
1. **Versioning strategy** — Explicitly state whether using URL path (/api/v1/) or Accept header versioning
2. **Inheritance strategy** — Document how new version controllers inherit from previous version
3. **Route definition** — Show the namespace route configuration in config/routes.rb
4. **Deprecation headers** — Include Deprecatable concern with sunset date configuration
5. **Compatibility specs** — Include the command to run backward compatibility specs
6. **Language** — Must be in English unless explicitly requested otherwise
## Extended Resources (Progressive Disclosure)
Load these files only when their specific content is needed:
- **[EXAMPLES.md](EXAMPLES.md)** — Use when you need complete API versioning examples with route definitions and controller inheritance
- **[references/strategies.md](references/strategies.md)** — Use when comparing versioning strategies (URL path vs header vs query param)
- **[references/workflow.md](references/workflow.md)** — Use when implementing the deprecation communication workflow and sunset scheduling
## Integration
| Skill | When to chain |
|-------|---------------|
| **generate-api-collection** | When generating the updated API endpoints |
| **test-engine** | When verifying specs for regressions |More API Design skills
lark-event
larksuite/cli
Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume <EventKey>` (covers IM messages/reactions/chat changes, Approval status changes, Task updates, VC meeting started/joined/ended, Minutes generated, Whiteboard updated, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses.
lark-contact
larksuite/cli
飞书 / Lark 通讯录:按姓名 / 邮箱解析成 open_id,或按 open_id 反查姓名 / 部门 / 邮箱 / 联系方式 / 个人状态 / 签名,以及按关键词搜索当前用户可见的机器人 / 智能体(agent)。当用户提到一个名字要下一步发消息 / 排日程,或拿到 open_id 想查具体信息时使用。不负责部门树遍历、按部门列员工、组织架构图,这类需求走原生 OpenAPI。
lark-openapi-explorer
larksuite/cli
飞书/Lark 原生 OpenAPI 探索:从官方文档库中挖掘未经 CLI 封装的原生 OpenAPI 接口。当用户的需求无法被现有 lark-* skill 或 lark-cli 已注册命令满足,需要查找并调用原生飞书 OpenAPI 时使用。

