lark-event
π―SkillThis skill lets your AI agent listen for live events in Lark (Feishu), a work chat app, such as new messages, approvals, task updates and meetings. The agent can then react to each event as it arrives.
Installation
npx skills add larksuite/cli --skill lark-eventRun it in a terminal; it asks which AI coding tools to install it for (Claude Code, Codex, Cursor and more).
Uses skills.sh Β· Node.js 22.20+
After installing
Ask for related work and the agent uses it on its own, or call it yourself.
/lark-eventInstall by hand
Copy the whole skill folder from GitHub to the place below. Copying only SKILL.md can leave out files the skill uses.
Open the skill folder β- This project
.claude/skills/lark-event/ - All projects
~/.claude/skills/lark-event/
These paths are for Claude Code. For other tools, the command above puts it in the right place.
What this skill does
Overview
This skill explains how to receive Lark/Feishu events with lark-cli event consume <EventKey>. Each event prints as one line of JSON (a common data format), a style called NDJSON, so a program can read events one at a time. It also sets clear rules for agents that run the command as a subprocess (a helper program started by another program), such as how to know it is ready and how to stop it safely.
Key Features
- Find the events you can subscribe to with
lark-cli event listand check each event's fields withlark-cli event schema <EventKey>. - Receive events for messages, reactions, approvals, tasks, video meetings, Minutes, whiteboards and document comments.
- Stop a run after a set number of events with
--max-eventsor after a set time with--timeout. - Filter or reshape each event with a
--jqexpression (jq is a tool for working with JSON), or save each event as a file with--output-dir. - Start reading after the
[event] ready event_key=<key>line appears, and use exit codes to tell normal finishes from failures.
Who is this for?
It is for developers who build Lark bots or tools that must handle new messages and updates in real time. It also helps people who run agents for a long time, for example by warning that kill -9 can leave old subscriptions on the server.
Summarized by AI from this skill's SKILL.md. Suggest a better one
SKILL.md
View on GitHub β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, Drive doc comment notices, 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 Events
Prerequisite: Read
../lark-shared/SKILL.mdfirst for authentication,--as user/botswitching,Permission deniedhandling, and safety rules.
Core commands
| Command | Purpose |
|---|---|
lark-cli event list [--json] | List all subscribable EventKeys |
lark-cli event schema <EventKey> [--json] | Show an EventKey's params and output schema |
lark-cli event consume <EventKey> [flags] | Blocking consume; events β stdout NDJSON |
lark-cli event status [--json] [--fail-on-orphan] | Inspect the local bus daemon status |
lark-cli event stop [--all] [--force] | Stop the bus daemon |
Common flags
| Flag | Description |
|---|---|
--param key=value / -p | Business params (repeatable; comma-separated for multi-value). Unknown keys fail with valid names listed inline |
--jq <expr> | jq expression to filter / transform each event; empty output skips the event |
--max-events N | Exit after N events. Default 0 = unlimited |
--timeout D | Exit after duration D (e.g. 30s, 2m). Default 0 = no timeout. Whichever of --max-events / --timeout fires first wins |
--output-dir <dir> | Write each event as a file (relative paths only; prevents traversal) |
--quiet | Suppress ready/exit markers and per-event stderr diagnostics, including drop warnings. This can hide event loss. AI should not use this β it removes readiness and integrity signals |
--as user|bot|auto | Identity for the session (see lark-shared) |
Examples
# Default: stream every event for the key (no filter, no projection)
lark-cli event consume im.message.receive_v1 --as bot
# List every EventKey of one domain (the authoritative, always-current catalog)
lark-cli event list --domain vc --json
# Grab one sample event to inspect payload shape
lark-cli event consume im.message.receive_v1 --max-events 1 --timeout 30s --as bot
# Run for 10 minutes then auto-exit
lark-cli event consume im.message.receive_v1 --timeout 10m --as bot
# Consume multiple EventKeys concurrently (one shape per process, no dispatcher)
lark-cli event consume im.message.receive_v1 --as bot > receive.ndjson &
lark-cli event consume im.message.reaction.created_v1 --as bot > reaction.ndjson &
wait
Call flow
lark-cli event list --jsonβ pick a legal key.--domain <d>narrows to one domain; the domains areapplication,approval,board,card,drive,im,minutes,task,vc. An unknown domain fails with the valid set listed in the hint.lark-cli event schema <key> --jsonβ readresolved_output_schema+jq_root_pathto determine field pathslark-cli event consume <key> [--jq '<expr>']β consume
Subprocess contract
Ready marker
event consume's stderr emits a fixed line [event] ready event_key=<key>. Parent processes should block on stderr until this line appears, then start reading stdout. Do not fall back to sleep.
stdin EOF = graceful exit
event consume treats stdin close as a shutdown signal (wired for AI subprocess callers). Bounded runs are exempt: when --max-events or --timeout is set (> 0), stdin EOF is ignored and the run exits only via its own bound, timeout, or SIGTERM. For unbounded runs, < /dev/null / nohup / systemd's default StandardInput=null will cause an immediate graceful exit (stderr reason: signal). To keep an unbounded run alive:
- Feed stdin a source that never EOFs:
< <(tail -f /dev/null) - Or run bounded:
--max-events N/--timeout D
Exit codes & reason
On exit, the last stderr line is [event] exited β received N event(s) in Xs (reason: ...).
| exit code | reason | Trigger |
|---|---|---|
| 0 | reason: limit | --max-events reached |
| 0 | reason: timeout | --timeout reached |
| 0 | reason: signal | Ctrl+C / SIGTERM / stdin EOF (stdin EOF applies to unbounded runs only) |
| 1 | JSON error envelope on stderr | Lark API business failure during pre-consume setup (for example subscription create/delete) |
| 2 | JSON error envelope on stderr (no exited line) | Validation failure (unknown EventKey, bad --param / --jq, another bus already connected) |
| 3 | JSON error envelope on stderr | Auth failure (missing token, missing scopes) |
| 4 / 5 | JSON error envelope on stderr | Network / internal failure (bus startup, handshake, file I/O) |
Startup and runtime failures emit a structured JSON envelope on stderr: {"ok":false,"error":{"type","subtype","param","message","hint",...}} (the envelope may also carry top-level identity / _notice siblings). Parse error.type / error.subtype to branch (e.g. missing_scope carries a missing_scopes list), error.param to find the offending flag, and error.hint for the recovery action β do not regex-match message text.
Orchestrators should treat reason: limit/timeout/signal (all exit 0) as "business completion" and non-zero as "failure".
Never kill -9
Avoid kill -9 on consume processes for EventKeys whose PreConsume registers a server-side subscription and unsubscribes on exit (minutes, vc, board keys): kill -9 skips the OAPI unsubscribe and leaks the server-side subscription (symptoms: "subscription already exists" on restart, duplicate event delivery). Keys whose subscription is a durable relation with no cleanup (task, approval, drive keys) do not leak this way, but SIGTERM or closing stdin remains the right shutdown for every key.
One consume, one EventKey (multi-key = multi-shell)
The command takes exactly one positional argument; k1,k2 and wildcards are unsupported. Listening to N keys means N subprocesses β this is intentional:
- One shape per process stdout; no dispatcher logic required in the AI
- Fault isolation (one key failing doesn't affect others)
- Independent
--as/--jq/--max-events/--timeoutper key
All N consumers share a single bus daemon (UDS local IPC), so the overhead is small
Writing jq via schema
event schema <key> --json is the source of truth for writing --jq. Four things to look at:
(1) Where fields start β see jq_root_path
- Value
"."β fields are at the top level, write.chat_id - Value
".event"β fields are inside a V2 envelope, write.event.chat_id
(2) Field list and types β see resolved_output_schema.properties.<name>
Each field carries type / description, and some also have format. Snippet (from event schema im.message.receive_v1 --json):
{
"chat_id": {"type":"string", "format":"chat_id", "description":"Chat ID, prefixed with oc_"},
"sender_id": {"type":"string", "format":"open_id", "description":"Sender open_id, prefixed with ou_"},
"create_time": {"type":"string", "format":"timestamp_ms", "description":"Send time as ms-epoch string"}
}
(3) Field semantics β see the format tag
Lark-defined semantic tags (not JSON Schema's standard format). Common values: open_id / chat_id / message_id / timestamp_ms / email. Purpose: distinguish "same string type, different meanings" fields so you can reverse-lookup via API or convert formats.
(4) Decoded state β read the field's description
event consume runs Process hooks that may pre-decode some payload fields (flattening V2 envelopes, rendering .content to plain text, etc.) β behavior differs from raw OAPI. Always read the field's description before writing jq, especially for generic field names like content / data / body / payload.
Why it matters: blindly applying fromjson to an already-decoded text field makes jq error on every event and silently drop it β the consumer looks alive but emits nothing, with only a single WARN line buried on stderr. (This is the general behavior: any jq runtime error skips the event with a one-line WARN; the loop does not abort.)
Don't shortcut the schema: when projecting event schema --json with jq, do not strip .description from properties β that's the field that tells you whether a field is already decoded. Dump the full property objects, not just keys.
Aside: --param's valid parameters also live in the schema β the params section lists name / type / required / enum / default / description; section missing = this key accepts no --param.
Topic index
| Topic | Reference | Coverage |
|---|---|---|
| Application | references/lark-event-application.md | Catalog of Application EventKeys, including application.bot.menu_v6 for custom bot menu push events + flattened event_key / operator fields + jq recipe |
| Approval | references/lark-event-approval.md | Catalog of 2 Approval EventKeys (approval.instance.status_changed_v4, approval.task.status_changed_v4) + optional/multi subscription_type pre-registration + user-auth subscription lifecycle + flat output field reference |
| Drive | references/lark-event-drive.md | Catalog of 1 Drive EventKey (drive.notice.comment_add_v1) for doc comment / reply notices (@bot or @me) + user vs bot receiver semantics + durable subscription + flat field reference + follow-up comment read |
| IM | references/lark-event-im.md | Catalog of 12 IM EventKeys + shape notes (flat vs V2 envelope) + im.message.receive_v1 field gotchas (sender_id is open_id only; .content is plain text except for interactive cards) + common jq recipes (filter by chat_type / message_type / sender); for card.action.trigger see also ../lark-im/references/lark-im-card-action-reply.md |
| Task | references/lark-event-task.md | Catalog of 1 Task EventKey (task.task.update_user_access_v2) + Native V2 envelope shape + task commit types + user/bot subscription notes |
| VC | references/lark-event-vc.md | Catalog of 7 VC EventKeys (meeting lifecycle participant_meeting_started/joined/ended_v1, vc.note.generated_v1, recording recording_started/transcript_generated/ended_v1) + field reference + source type semantics; the live list is always lark-cli event list --domain vc --json |
| Minutes | references/lark-event-minutes.md | Catalog of 1 Minutes EventKey (minutes.minute.generated_v1) + field reference + source type semantics (meeting only) |
| Whiteboard | references/lark-event-whiteboard.md | Catalog of 1 Board EventKey (board.whiteboard.updated_v1) + per-whiteboard subscription model (requires -p whiteboard_id=<token>) + payload field reference (whiteboard_id / operator_ids triple-id) |
More from this repository10
Lets Claude read, search, organize and write your Feishu (Lark) email from the command line. New messages are saved as drafts first, and nothing is sent until you approve it.
Helps your AI assistant find people in Feishu/Lark, a workplace messaging app, by name or email, and search for bots by keyword. It can also show a person's department, email, status or profile signature.
This skill lets your AI use features of Feishu/Lark, a workplace chat and office app, that lark-cli has no command for yet. It looks them up in the official docs step by step and then calls them with `lark-cli api`.
Helps you write your own skills for lark-cli, the command-line tool for Feishu (Lark). A skill is a SKILL.md file that teaches your AI a Feishu task, from one action to a multi-step process.
Lets your AI agent create, read and edit presentations in Lark (Feishu) Slides. It plans each deck first and checks every slide's layout before saving it.
A skill that helps your AI agent build, publish and run apps on Miaoda (Spark), the app building and hosting service in Feishu/Lark. It also manages app data, logs, settings, team access and automatic tasks.
Part of the official Lark/Feishu CLI, providing 200+ commands and 26 AI agent skills across 18 business domains including Messenger, Docs, Sheets, Calendar, and Mail. Designed for both humans and AI agents with agent-friendly structured output.
The official Lark/Feishu CLI tool providing 200+ commands and 26 AI agent skills across core business domains including Messenger, Docs, Base, Sheets, Calendar, Mail, Tasks, and Meetings.
Part of the official Lark/Feishu CLI tool with 200+ commands and 26 AI agent skills across 18 business domains including Calendar, Messenger, Docs, Sheets, Base, Tasks, and Mail, featuring agent-native design and structured output.
The official Lark/Feishu CLI tool with 200+ commands and 26 AI agent skills covering Messenger, Docs, Base, Sheets, Calendar, Mail, Tasks, Meetings, and more. Designed for both humans and AI agents.