chat / adapter-linear
AGENTS.md2.4k starsChanged 59 days agoMITView on GitHub
Guidance for coding agents working inside the Linear adapter package. The top-level repository AGENTS.md covers monorepo-wide build, lint, and release rules — read it first. This file documents the adapter-specific surface, conventions, and pitfalls. @chat-adapter/linear connects a Chat SDK bot to issue and project comment threads inside Linear. It covers: - HTTP webhook endpoint at /api/webhooks/linear for Issue.create / update / remove, Comment.create / update / remove, IssueLabel, and Reaction events, validated via the Linear webhook signing secret. - Comment…
- Reads credentials
Trending
Quiet since March.thin dataabout the whole repository
Who's talking about vercel/chat
- @camilleroux.com“Un SDK TypeScript unifié pour créer des chatbots qui fonctionnent sur Slack, Teams, Google Chat, Discord, …”Bluesky · Mar 3, 2026 · 3 likes
- @technews4869.bsky.social“github.com/vercel/chat GitHub - vercel/chat: A unified TypeScript SDK for building chat bots across Slack, …”Bluesky · Mar 7, 2026 · 1 likes
- @yug1224.com“チャットアプリ開発に使える統一SDKを提供するツールらしい 様々なプラットフォーム対応で便利そうだな yug1224 starred vercel/chat https://github.com/vercel/chat”Bluesky · Mar 7, 2026 · 1 likes
- @news.humancoders.com“Vercel lance Chat SDK : un SDK TypeScript unifié pour créer des bots multi-plateformes”Bluesky · Mar 5, 2026 · 1 likes
- @github-trending-js.bsky.social“🔥 Hot Repo! 🔥 (100+ new stars) 📦 vercel / chat ⭐ 871 (+121) 🗒 TypeScript A unified TypeScript SDK for …”Bluesky · Feb 27, 2026 · 1 likes
The biggest 5 of 5 mentions linking to the repository that our crawl found. Each line is their own headline.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- apps/docs/AGENTS.mdAGENTS.md
- chat-sdkAGENTS.md
- packages/adapter-discord/AGENTS.mdAGENTS.md
- packages/adapter-gchat/AGENTS.mdAGENTS.md
- packages/adapter-github/AGENTS.mdAGENTS.md
- packages/adapter-instagram/AGENTS.mdAGENTS.md
- packages/adapter-messenger/AGENTS.mdAGENTS.md
- packages/adapter-notion/AGENTS.mdAGENTS.md
- packages/adapter-slack/AGENTS.mdAGENTS.md
- packages/adapter-teams/AGENTS.mdAGENTS.md
- packages/adapter-telegram/AGENTS.mdAGENTS.md
- packages/adapter-web/AGENTS.mdAGENTS.md
- packages/adapter-whatsapp/AGENTS.mdAGENTS.md
- packages/chat/src/adapters/AGENTS.mdAGENTS.md
- packages/create-chat-sdk/AGENTS.mdAGENTS.md
- packages/create-chat-sdk/_template/AGENTS.mdAGENTS.md
- packages/state-ioredis/AGENTS.mdAGENTS.md
- packages/state-memory/AGENTS.mdAGENTS.md
- packages/state-pg/AGENTS.mdAGENTS.md
- packages/state-redis/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- packages/adapter-discord/CLAUDE.mdCLAUDE.md
- packages/adapter-gchat/CLAUDE.mdCLAUDE.md
- packages/adapter-github/CLAUDE.mdCLAUDE.md
- packages/adapter-linear/CLAUDE.mdCLAUDE.md
- packages/adapter-messenger/CLAUDE.mdCLAUDE.md
- packages/adapter-slack/CLAUDE.mdCLAUDE.md
- packages/adapter-teams/CLAUDE.mdCLAUDE.md
- packages/adapter-telegram/CLAUDE.mdCLAUDE.md
- packages/adapter-web/CLAUDE.mdCLAUDE.md
- packages/adapter-whatsapp/CLAUDE.mdCLAUDE.md
- packages/create-chat-sdk/CLAUDE.mdCLAUDE.md
- packages/create-chat-sdk/_template/CLAUDE.mdCLAUDE.md
- packages/state-ioredis/CLAUDE.mdCLAUDE.md
- packages/state-memory/CLAUDE.mdCLAUDE.md
- packages/state-pg/CLAUDE.mdCLAUDE.md
- packages/state-redis/CLAUDE.mdCLAUDE.md
- add-adapterSkill
- technical-writerSkill
- chat-sdkSkill
- chat-sdkSkill
- chat-sdkSkill
- chat-sdkSkill
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 217
When you add a new event type or mutation, capture a fresh fixture in sample-messages.md.
- Distinctive: line 222
Use named exports throughout.
- Very specific: line 229
Always pass tokens through withInstallationToken instead of reading them ad-hoc from state.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — @chat-adapter/linear
Guidance for coding agents working inside the Linear adapter package. The top-level repository AGENTS.md covers monorepo-wide build, lint, and release rules — read it first. This file documents the adapter-specific surface, conventions, and pitfalls.
Overview
@chat-adapter/linear connects a Chat SDK bot to issue and project
comment threads inside Linear. It covers:
- HTTP webhook endpoint at
/api/webhooks/linearforIssue.create / update / remove,Comment.create / update / remove,IssueLabel, andReactionevents, validated via the Linear webhook signing secret. - Comment posting and editing via Linear's GraphQL API.
- OAuth-based authentication with installation tokens stored per workspace, plus a personal-API-key fallback for single-tenant bots.
- Reactions (Linear has its own emoji set + custom emoji per workspace).
- Issue thread routing — top-level comments belong to an issue's
thread; threaded replies attach via
parentId.
Directory layout
packages/adapter-linear/
├── src/
│ ├── index.ts # LinearAdapter + createLinearAdapter
│ ├── index.test.ts
│ ├── cards.ts # PostableMessage / Card → Linear comment body
│ ├── cards.test.ts
│ ├── markdown.ts # LinearFormatConverter (mdast ↔ Linear MD)
│ ├── markdown.test.ts
│ ├── utils.ts # GraphQL helpers, identifier parsing
│ ├── utils.test.ts
│ └── types.ts # Linear webhook + GraphQL typings
├── sample-messages.md # captured Linear webhook deliveries
├── package.json
├── tsconfig.json
├── tsup.config.ts
├── vitest.config.ts
└── README.mdBuild, test, typecheck
pnpm build
pnpm dev
pnpm test
pnpm test:watch
pnpm typecheck
pnpm clean
# from repo root
pnpm --filter @chat-adapter/linear build
pnpm --filter @chat-adapter/linear testReplay tests live in
packages/integration-tests/src/replay-linear-*.test.ts.
Public surface
Main exports from src/index.ts:
createLinearAdapter(config?)— primary factory. Auto-detectsLINEAR_API_KEY(personal token),LINEAR_OAUTH_CLIENT_ID,LINEAR_OAUTH_CLIENT_SECRET, andLINEAR_WEBHOOK_SECRET.LinearAdapterclass — implementsAdapter<LinearThreadId, unknown>. Public methods:handleWebhook,postMessage,editMessage,deleteMessage,addReaction,removeReaction,fetchThread,listThreads,fetchMessages,fetchSingleMessage,fetchChannelInfo,postChannelMessage,openDM,getInstallation,setInstallation,handleOAuthCallback.- Configuration:
LinearAdapterConfig,LinearThreadId,LinearInstallation. - Helpers:
cardToMarkdown,cardToFallbackText,LinearFormatConverter,decodeThreadId,encodeThreadId,isDM.
Thread ID format
Linear identifiers use the team-key + counter shape (ENG-123).
The adapter encodes the workspace and identifier:
linear:{workspaceSlug}:{issueId} # issue-level thread
linear:{workspaceSlug}:{issueId}:{parentCommentId} # threaded replyencodeThreadId / decodeThreadId are the canonical constructors
(see utils.ts). Linear has no native DM concept, so isDM always
returns false.
Webhook flow
LinearAdapter.handleWebhook(request, options) is the entry point.
- Signature verification — Linear signs the body with HMAC-SHA256
and includes the timestamp in
Linear-Delivery. The adapter verifies both with timing-safe comparison, rejecting payloads more than 5 minutes old. - Event routing
Comment(create,update,remove) →chat.handleIncomingMessage(or edit / delete hooks).Issue(create,update,remove) → optional issue lifecycle hooks;createevents with the bot @mentioned in the description also firechat.handleIncomingMessage.IssueLabel→ optional label hooks.Reaction(create,remove) →chat.handleReaction.
- Token resolution — every outbound GraphQL call uses
withInstallationToken(workspaceId, …)for OAuth-installed workspaces, or the personal API key when configured.
Authentication
Two modes:
- Personal API key (
apiKey) — single-workspace bots. Authenticates as the user who issued the key. Use the app user token for clean attribution; standard user tokens still work but attribute comments to the human. - OAuth (
clientId+clientSecret) — multi-workspace.handleOAuthCallbackexchanges the auth code, persists the resulting access token in state under{installationKeyPrefix}:{workspaceId}, and refreshes ahead of expiry.
The personal API key path bypasses the state adapter for token resolution; OAuth always reads/writes installations.
Format conversion
LinearFormatConverter (in markdown.ts) maps:
- mdast → Linear Markdown — Linear renders a near-CommonMark subset
with extensions:
[ ]checkboxes (in lists),:emoji:shortcodes, inline code, fenced code with language hints, and@mentionsvia@user-name. - Linear Markdown → mdast — round-trips the same constructs. Mentions
become
linknodes pointing at@user-name. The converter keeps emoji shortcodes intact rather than expanding to Unicode so the UI can render the workspace's custom emoji. - Tables — Linear supports GFM tables; the converter passes them through unchanged.
Cards (markdown comments)
cardToMarkdown walks a Chat SDK Card JSX tree:
- Header / Section → markdown headings and paragraphs.
- Field → bulleted
**label:** valuelines. - Image → markdown image with the comment-attachment URL when binary
data is provided (uploaded via the GraphQL
attachmentUploadmutation first). - Buttons / LinkButtons → markdown links to a deep-link URL. Linear doesn't render interactive buttons inside comments.
- Divider →
---. - Table → GFM table.
cardToFallbackText is identical to cardToMarkdown for this
adapter.
Streaming
Linear comments cannot be edited indefinitely (the GraphQL mutation returns 403 after the comment is more than 24h old in some workspaces). The adapter follows the post-then-edit pattern with a 3-second min interval and stops editing once the stream completes or the comment ages out.
Reactions
addReaction(threadId, messageId, emoji) accepts:
- Unicode emoji (
👍). - Linear shortcodes (
thumbs_up). - Custom emoji names (
my_workspace_emoji).
The adapter normalises these via utils.ts before sending the
GraphQL mutation. Removing a reaction requires the reaction id; the
adapter looks it up from the in-memory reaction cache populated by
inbound Reaction.create events.
Linear quirks worth remembering
- Three identity flavours. Personal user tokens, OAuth user tokens, and OAuth app-user tokens. Comment attribution differs; always prefer the app-user token for bot-style attribution.
- Webhook delivery latency. Linear can deliver events out of order during high-traffic windows. Handlers must be idempotent.
- Comment edit window. Older comments cannot be edited; surface this gracefully when streaming aborts.
- Workspace-scoped emoji. Reactions accept unicode plus the workspace's custom emoji set. There is no global emoji namespace.
- GraphQL pagination.
fetchMessages/fetchChannelMessagesuse cursor pagination viapageInfo.endCursor— keep cursors out of public types. - Issue identifiers vs IDs.
ENG-123is the human identifier shown in URLs, but the GraphQL API expects the UUID.utils.tsresolves identifiers to UUIDs via a single GraphQL query.
Testing approach
- Unit tests colocated with each module (
*.test.ts). The GraphQL request shape tests inutils.test.tsare the most comprehensive — extend them when adding new mutations or queries. - Replay tests in
packages/integration-tests/src/replay-linear-*.test.tsconsume recorded webhook deliveries. - GraphQL transport is mocked at the
fetchboundary; never hitapi.linear.appfrom unit tests.
When you add a new event type or mutation, capture a fresh fixture
in sample-messages.md.
Coding conventions
- Use named exports throughout. No default exports.
- GraphQL helpers belong in
utils.ts— keepindex.tsfocused on the adapter contract. - Errors map to
@chat-adapter/shared(AuthenticationError,AdapterRateLimitError,NetworkError,ValidationError). - Top-level regex literals (
IDENTIFIER_REGEX,MENTION_REGEX, etc.). - Always pass tokens through
withInstallationTokeninstead of reading them ad-hoc from state.
Releases
Behavioural changes need a changeset (pnpm changeset, choose
@chat-adapter/linear plus chat if a public type changed). Sample
fixtures and AGENTS.md edits don't.
Where to look next
- User-facing docs:
apps/docs/content/adapters/official/linear.mdx - README:
packages/adapter-linear/README.md - Shared error/utility helpers:
packages/adapter-shared/src/index.ts - Core Adapter contract:
packages/chat/src/adapter.ts - Sample webhook payloads:
packages/adapter-linear/sample-messages.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

