Skip to content

docs(mail): trim lark-mail skill context - #1527

Merged
bubbmon233 merged 1 commit into
mainfrom
jiayi/mail-skill-token-trim
Jun 22, 2026
Merged

docs(mail): trim lark-mail skill context#1527
bubbmon233 merged 1 commit into
mainfrom
jiayi/mail-skill-token-trim

Conversation

@bubbmon233

@bubbmon233 bubbmon233 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Trim the lark-mail skill entry so the always-loaded context focuses on core workflows, safety rules, and command selection. Less common raw API and scope details are now handled through command help and schema discovery.

Changes

  • Condense low-frequency mail operations and raw API resource listings into discovery guidance.
  • Keep safety, identity selection, send-status, template, and raw API parameter rules in the main entry.
  • Clarify that multiple known message IDs should be read with +messages instead of repeated +message calls.

Test Plan

  • Unit tests pass (not run; documentation-only change)
  • Manual local verification confirms the lark-cli mail documentation flow remains consistent (git diff --check)

Related Issues

  • None

Summary by CodeRabbit

Documentation

  • Lark Mail skill documentation updated – Narrowed scope to mail/email intent, improved pre-flight guidance, and clarified when to use help (-h) for uncertain flags/parameters. Refreshed typical workflows for batch reads (+messages) and full conversations (+thread), tightened HTML/validation guidance (--html=false), and restructured native API usage into a discover-and-construct flow.
  • New reference: Email recall – End-to-end recall prerequisites, commands, progress, and status interpretation.
  • New references: Receiving rules, recipient search, send-as, send status, and templates – Each includes prerequisites, example command flows, and practical constraints/checklists.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

skills/lark-mail/SKILL.md is revised to narrow scope to mail-only, reduce mandatory pre-reads, restrict the -h discovery rule to uncertain parameters, condense low-frequency operation walkthroughs into reference pointers, update batch message read guidance, and replace the static API Resources/Permissions table with a dynamic Raw API Discovery flow. Six new reference documents provide guided workflows for recipient search, mail recall, mailbox rule management, send-as operations, send status confirmation, and email templates.

Changes

Lark Mail skill documentation overhaul and feature references

Layer / File(s) Summary
Scope, pre-reads, and parameter discovery narrowing
skills/lark-mail/SKILL.md
Shortens the top-level description to mail-only intent, replaces mandatory pre-read requirements for lark-shared and lark-mail-html references with conditional "only when needed" guidance, and narrows the -h rule from "before first use" to "when parameters/resources/raw API structure are uncertain," clarifying that -h output is the authoritative source for flag names.
Typical workflow: batch reads, HTML control, and shortcuts clarity
skills/lark-mail/SKILL.md
Updates the read step to use +messages for multiple message_id values instead of looping +message; adjusts --html=false guidance for token reduction in validation-only confirmations; adds an explicit multi-ID batch example with +messages --message-ids; and updates the shortcuts table to restrict +message to single-ID reads, clarify +messages for multi-ID batching, and explicitly discourage looping.
Low-frequency operations, recipient search, and raw API discovery
skills/lark-mail/SKILL.md
Condenses 低频操作 send-as and post-send handling into short reference pointers; compacts 收件人搜索 guidance to point to dedicated reference doc; replaces the large static "API Resources + Permissions table" with a compact Raw API Discovery section describing the -h → resource/method discovery → schema--params/--data construction flow.
Recipient search reference
skills/lark-mail/references/lark-mail-recipient-search.md
New reference covering prerequisites, when search is needed (human-named vs. keyword vs. group vs. direct email), multi_entity search command format, result type/tag mapping for users/groups/contacts, filtering and confirmation rules, display guidance for single and multiple matches, and related send/draft commands.
Mail recall reference
skills/lark-mail/references/lark-mail-recall.md
New reference specifying prerequisites, when recall applies (based on recall_available in send responses), command examples for initiating recall and retrieving details, return-value status interpretation (available/unavailable, in_progress/done, outcomes), typical async workflow, and cross-references to send/reply/forward commands.
Mailbox rules reference
skills/lark-mail/references/lark-mail-rules.md
New reference for receiving-rule operations using native APIs (create/list/update/reorder/delete) without shortcuts; includes write-operation preconditions (preview + confirmation), a complete CLI example creating and validating a subject-text-contains rule, Raw API discovery instructions via lark-cli help/schema, and related label-lookup and message-modification commands.
Send-as and mailbox alias reference
skills/lark-mail/references/lark-mail-send-as.md
New reference covering prerequisites, --mailbox and --from parameter meanings and optionality, command examples for querying accessible mailboxes and send-as addresses, public mailbox send example (auto-From), alias/secondary address send example (explicit --from), and cross-references to send/draft/reply/forward commands.
Send status confirmation reference
skills/lark-mail/references/lark-mail-send-status.md
New reference covering immediate-send confirmation (invoke send_status using message_id from send response and report status codes via table), send-interception handling (skip send_status when automation_send_disable_reason is present; show reason and draft link instead), scheduled-send deferral (no message_id until actual send), cancellation via cancel_scheduled_send, and related send/reply/forward commands.
Email template reference
skills/lark-mail/references/lark-mail-template.md
New reference covering template use cases, creation/update and application in send/draft/reply/forward shortcuts, field merge rules (recipient/subject/body precedence, attachment collision handling, cid behavior), warnings for non-deduplicated recipients in reply flows, size constraints and Large-format fallback behavior, and native API examples for user_mailbox.templates list/get/delete operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • larksuite/cli#1261: Aligns the mail-reading shortcut guidance by distinguishing single +message (one message_id) vs. batch +messages (comma-separated --message-ids) and updates related documentation/help text accordingly, directly overlapping with the batch-read changes here.
  • larksuite/cli#749: Modifies skills/lark-mail/SKILL.md with safety and compliance rules that cross-reference the "API Resources" section being replaced by the new Raw API Discovery section in this PR.
  • larksuite/cli#437: Adds documentation for the same "recipient/contact search" workflow centered on lark-cli mail multi_entity search, including result type interpretation and passing selected email into compose --to/--cc/--bcc parameters.

Suggested labels

size/M

Suggested reviewers

  • chanthuang

Poem

🐇 Hop, hop — the docs grew lean,
No more must-reads cluttering the scene!
Batch your messages, -h when unsure,
Raw API discovery, clean and pure.
Recall and rules and templates too,
The rabbit's guides help you break through! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs(mail): trim lark-mail skill context' directly and concisely describes the main change: trimming documentation context for the mail skill.
Description check ✅ Passed The description covers summary, changes, test plan, and related issues sections; however, the test plan checkboxes are incomplete (unit tests checkbox is unchecked and marked as not run).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jiayi/mail-skill-token-trim

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added domain/mail PR touches the mail domain size/L Large or sensitive change across domains or core paths labels Jun 22, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
skills/lark-mail/SKILL.md (1)

130-130: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Minor: Chinese grammar could be clarified (non-blocking).

The phrase "-h 输出是可用 flag 的权威来源" is grammatically acceptable but slightly awkward. Consider rewording to "-h 输出是确定可用 flag 的权威来源" or "-h 的输出是 flag 名称的权威来源" for clarity. This is very low-priority and does not affect understanding.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/lark-mail/SKILL.md` at line 130, The Chinese grammar in the SKILL.md
documentation sentence could be clarified for better readability. In the
sentence starting with "`-h` 输出是可用 flag 的权威来源", reword the phrase to either
"`-h` 输出是确定可用 flag 的权威来源" or "`-h` 的输出是 flag 名称的权威来源" to make the meaning
clearer and the grammar more natural. This improves clarity without changing the
intended meaning.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@skills/lark-mail/SKILL.md`:
- Line 130: The Chinese grammar in the SKILL.md documentation sentence could be
clarified for better readability. In the sentence starting with "`-h` 输出是可用 flag
的权威来源", reword the phrase to either "`-h` 输出是确定可用 flag 的权威来源" or "`-h` 的输出是 flag
名称的权威来源" to make the meaning clearer and the grammar more natural. This improves
clarity without changing the intended meaning.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbb1303d-5640-441c-af1c-6ef8ebbe69fa

📥 Commits

Reviewing files that changed from the base of the PR and between bba13cf and 97a0de0.

📒 Files selected for processing (1)
  • skills/lark-mail/SKILL.md

@bubbmon233
bubbmon233 force-pushed the jiayi/mail-skill-token-trim branch 5 times, most recently from 72b9227 to 81c24ab Compare June 22, 2026 04:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
skills/lark-mail/references/lark-mail-rules.md (2)

35-35: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Document the quick-code mappings more explicitly.

Line 35 ("Quick codes above: condition type=2 = subject, operator=2 = contains, action type=2 = add label") maps numeric codes to human-readable names, but only inline as a comment. Consider adding a reference table or link to the official API documentation so users can independently discover other code values for conditions and actions.

The reference could include a note like:

For complete list of condition/action type codes, see API schema or run:
lark-cli schema mail.user_mailbox.rules.create
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/lark-mail/references/lark-mail-rules.md` at line 35, The quick codes
mapping for condition types, operators, and action types on line 35 are
currently documented only as an inline comment, making them difficult to
discover. Replace this inline comment with a dedicated reference section or
table in the document that explicitly lists the numeric code mappings for
conditions, operators, and actions. Include a note directing users to the
official API documentation or provide the CLI command (such as lark-cli schema
mail.user_mailbox.rules.create) so users can independently discover additional
code values beyond what is shown in the quick reference.

35-35: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Add link or reference to API schema for condition/action type codes.

Line 35 documents quick-reference codes inline ("condition type=2 = subject, operator=2 = contains, action type=2 = add label"), but only as a comment. To help users discover other available codes (e.g., for conditions: from/to/cc, for actions: move/delete/mark-read), add a reference to the schema discovery command:

Suggested addition after line 35
 Quick codes above: condition `type=2` = subject, `operator=2` = contains, action `type=2` = add label.
+
+For complete condition/action type mappings, see:
+```bash
+lark-cli schema mail.user_mailbox.rules.create
+lark-cli schema mail.user_mailbox.rules.update
+```
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/lark-mail/references/lark-mail-rules.md` at line 35, The quick
reference codes documented inline in the lark-mail-rules.md file at line 35 only
show specific examples but don't help users discover other available codes for
conditions and actions. After the line containing "Quick codes above: condition
`type=2` = subject, `operator=2` = contains, action `type=2` = add label.", add
a new section that references the schema discovery commands for
mail.user_mailbox.rules.create and mail.user_mailbox.rules.update to help users
find all available condition/action type codes and operator options through the
CLI schema command.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/lark-mail/references/lark-mail-rules.md`:
- Around line 22-25: In the lark-cli mail rule creation command example, correct
the semantic mismatch between numeric codes and their intended behavior. Change
the condition type from 2 to 6 to properly match "Subject" (not "Recipient")
with the provided subject_text parameter. Change the condition operator from 2
to 1 to match "contains" logic (not "does not contain"). Additionally, clarify
the action type: the current type=2 means "Delete it", but the example suggests
label functionality with the label_id parameter; either change to type=11 for
"Move to user folder" or update the parameter placeholder to reflect the actual
intended action based on the documented API behavior.

In `@skills/lark-mail/SKILL.md`:
- Around line 391-400: The SKILL.md documentation for the `+messages` shortcut
claims that the CLI handles more than 20 IDs in batches and merges output, but
this batching behavior is not documented in the corresponding reference guide
`lark-mail-messages.md`. Update the reference documentation to include the
auto-batching behavior with specific details: the exact batch size threshold,
the merge and deduplication strategy (including order preservation and handling
of unavailable IDs), and any limitations or ordering guarantees. This ensures
consistency between the overview documentation and the reference guide.

---

Nitpick comments:
In `@skills/lark-mail/references/lark-mail-rules.md`:
- Line 35: The quick codes mapping for condition types, operators, and action
types on line 35 are currently documented only as an inline comment, making them
difficult to discover. Replace this inline comment with a dedicated reference
section or table in the document that explicitly lists the numeric code mappings
for conditions, operators, and actions. Include a note directing users to the
official API documentation or provide the CLI command (such as lark-cli schema
mail.user_mailbox.rules.create) so users can independently discover additional
code values beyond what is shown in the quick reference.
- Line 35: The quick reference codes documented inline in the lark-mail-rules.md
file at line 35 only show specific examples but don't help users discover other
available codes for conditions and actions. After the line containing "Quick
codes above: condition `type=2` = subject, `operator=2` = contains, action
`type=2` = add label.", add a new section that references the schema discovery
commands for mail.user_mailbox.rules.create and mail.user_mailbox.rules.update
to help users find all available condition/action type codes and operator
options through the CLI schema command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e830aaf1-d9a1-4dfe-afa7-b69667039db6

📥 Commits

Reviewing files that changed from the base of the PR and between 207112d and 81c24ab.

📒 Files selected for processing (3)
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-recall.md
  • skills/lark-mail/references/lark-mail-rules.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-mail/references/lark-mail-recall.md

Comment thread skills/lark-mail/references/lark-mail-rules.md Outdated
Comment thread skills/lark-mail/SKILL.md Outdated
@bubbmon233
bubbmon233 force-pushed the jiayi/mail-skill-token-trim branch 6 times, most recently from 5e807f3 to 603ab27 Compare June 22, 2026 06:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
skills/lark-mail/references/lark-mail-rules.md (1)

22-35: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

** API payload codes are semantically incorrect for the documented intent.**

Per the past review, the numeric codes in the example contradict their intended behavior:

  • Condition type=2 actually means "Recipient" (not "Subject"); should be type=6 for subject matching.
  • Condition operator=2 actually means "Does not contain" (not "contains"); should be operator=1 for contains.
  • Action type=2 actually means "Delete it" (not "add label"); the API has no standard label action—use type=11 for "Move to user folder" or clarify the intended action.

The current example payload matches: "Recipient does NOT contain <subject_text> → Delete" instead of "Subject contains text → add label."

The quick reference on line 35 compounds the confusion by stating incorrect mappings as fact.

🐛 Proposed fix to align payload with documented intent
 # 2. 创建规则
 lark-cli mail user_mailbox.rules create --as user --yes \
   --params '{"user_mailbox_id":"me"}' \
-  --data '{"name":"<rule_name>","is_enable":true,"ignore_the_rest_of_rules":false,"condition":{"match_type":1,"items":[{"type":2,"operator":2,"input":"<subject_text>"}]},"action":{"items":[{"type":2,"input":"<label_id>"}]}}'
+  --data '{"name":"<rule_name>","is_enable":true,"ignore_the_rest_of_rules":false,"condition":{"match_type":1,"items":[{"type":6,"operator":1,"input":"<subject_text>"}]},"action":{"items":[{"type":11,"input":"<folder_id>"}]}}'

Also update line 35 to reflect the correct mappings:

-Quick codes above: condition `type=2` = subject, `operator=2` = contains, action `type=2` = add label.
+Quick codes above: condition `type=6` = subject, `operator=1` = contains, action `type=11` = move to folder. Update `<folder_id>` placeholder accordingly.

If "label" functionality is intended instead, clarify the action type and verify against current Lark Mail API documentation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/lark-mail/references/lark-mail-rules.md` around lines 22 - 35, The API
payload codes in the lark-cli mail user_mailbox.rules create command contain
incorrect numeric values that contradict the documented intent. In the condition
object, change type from 2 to 6 to correctly reference subject matching, and
change operator from 2 to 1 to correctly represent the "contains" operation. In
the action object, change type from 2 to an appropriate value such as 11 for
"Move to user folder" or clarify the intended action against current Lark Mail
API documentation. Finally, update the quick reference codes at the end of the
snippet to reflect the corrected mappings: condition type=6 = subject,
operator=1 = contains, and the updated action type value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@skills/lark-mail/references/lark-mail-rules.md`:
- Around line 22-35: The API payload codes in the lark-cli mail
user_mailbox.rules create command contain incorrect numeric values that
contradict the documented intent. In the condition object, change type from 2 to
6 to correctly reference subject matching, and change operator from 2 to 1 to
correctly represent the "contains" operation. In the action object, change type
from 2 to an appropriate value such as 11 for "Move to user folder" or clarify
the intended action against current Lark Mail API documentation. Finally, update
the quick reference codes at the end of the snippet to reflect the corrected
mappings: condition type=6 = subject, operator=1 = contains, and the updated
action type value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83a8a9e7-b35f-4574-82d3-5c1ed84b0abe

📥 Commits

Reviewing files that changed from the base of the PR and between 81c24ab and 603ab27.

📒 Files selected for processing (7)
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-recall.md
  • skills/lark-mail/references/lark-mail-recipient-search.md
  • skills/lark-mail/references/lark-mail-rules.md
  • skills/lark-mail/references/lark-mail-send-as.md
  • skills/lark-mail/references/lark-mail-send-status.md
  • skills/lark-mail/references/lark-mail-template.md
✅ Files skipped from review due to trivial changes (3)
  • skills/lark-mail/references/lark-mail-send-status.md
  • skills/lark-mail/references/lark-mail-recall.md
  • skills/lark-mail/references/lark-mail-send-as.md

@bubbmon233
bubbmon233 force-pushed the jiayi/mail-skill-token-trim branch 13 times, most recently from 92cbd62 to 97a758e Compare June 22, 2026 07:27
@bubbmon233
bubbmon233 force-pushed the jiayi/mail-skill-token-trim branch 4 times, most recently from 5f0923c to f13abf1 Compare June 22, 2026 08:12
chanthuang
chanthuang previously approved these changes Jun 22, 2026
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.79%. Comparing base (824aa9e) to head (c6b9eb7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1527   +/-   ##
=======================================
  Coverage   73.79%   73.79%           
=======================================
  Files         787      787           
  Lines       76142    76142           
=======================================
  Hits        56191    56191           
  Misses      15742    15742           
  Partials     4209     4209           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@c6b9eb7bc18ef0dfcc5d1986df9309b541f3aa1f

🧩 Skill update

npx skills add larksuite/cli#jiayi/mail-skill-token-trim -y -g

chanthuang
chanthuang previously approved these changes Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/mail PR touches the mail domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants