操作指南

AI coding 的语音输入指南:不用打字,用语音 prompt Cursor 和 Claude Code

当你能直接描述改动,而不是把它敲出来,vibe coding 会快很多。这里有 6 个完整示例、我们沉淀出的 prompt 模式,以及多语言标识符的处理方式。

TL;DR

如果你在找怎么用语音 prompt Cursor,或者怎么不用逐个拼写标识符也能把 Claude Code dictation 做对,这是一份实用指南。AI coding 的语音输入之所以有效,是因为 prompt 大多是普通语言:上下文、意图、约束和测试预期。Loqua 在此基础上加入了多模态屏幕上下文、结构化 prompt 格式、技术词汇处理,以及句中 EN+Chinese 混合输入。最值得用的 vibe coding voice 工作流包括:长 Cursor prompt、Claude Code debugging、重构规格和测试描述。很短的 "fix this" prompt 用语音不一定更快,真正的收益在信息密度高的指令里。

Loqua 是一款面向 Mac 的上下文感知语音输入工具。它会看你正在什么地方工作,并据此组织输出。对 AI coding 来说,这意味着它可以识别 Cursor 的聊天面板、Claude Code 的终端、ChatGPT 的 prompt 输入框,并输出这些工具最容易处理的 prompt 结构。

这不是一篇泛泛而谈的效率清单。我们自己每天都用语音做 AI coding;在长指令上,prompt 编写时间大约能减半,收益也最大。短 prompt("fix this")基本持平。长而结构化的 prompt(重构规格、多文件改动、debug 叙述)才是语音最划算的地方。

为什么语音适合 AI coding

AI coding prompt 的形态和代码不一样。一个好 prompt 通常有:上下文块(我在哪里、我看到了什么、我刚试了什么)、指令块(我想让它做什么)和约束(不要改 X、保留 Y、必须通过 Z 测试)。这是自然语言,不是语法,而自然语言正是语音擅长的部分。

你思考的速度比打字快,写普通文字时轻松快 2×。瓶颈不是你的 mental model,而是键盘输入成本。对于需要向 LLM 解释复杂情况的 prompt,这个差距很重要。Loqua 在基础听写之上补了三件事:它能看到 IDE 状态(所以上下文块可以自动写出来),它能结构化 prompt(system + user,或项目符号步骤列表),还能处理技术词汇,不需要你逐个拼写标识符。

AI coding 设置

本节假设你已经安装了 Loqua(可参考 我们的 Mac 语音写代码设置指南)。唯一和 AI coding 特别相关的配置,是授予 Loqua 辅助功能权限,这样它才能读取当前 app 的选区和相邻文本。macOS Accessibility 的说明在 developer.apple.com;这也是屏幕阅读器和自动化工具使用的同一类 API。

建议养成三个习惯:

  • 先选中,再说话。如果你希望 prompt 针对某个具体代码块,先把它选中。Loqua 会把选区作为上下文传入。
  • 打开内联聊天面板。Cursor 中,聊天面板可见会告诉 Loqua:你是在写 prompt,不是在编辑代码。
  • 用停顿表达结构分隔。半秒左右的停顿会被识别为 prompt 中的段落分隔,很适合把上下文和指令分开。

有效的 prompt 结构

经过几个月的语音 prompt,我们沉淀出三类最容易让 LLM 行为稳定的结构。Loqua 会读取你开头怎么 framing,然后据此组织输出。

你先说的 framing输出形态
"Refactor this so..."Refactor: [goal]. Constraints: [implicit from selection]. Output: [code].
"Debug this — when I X, Y happens but I expected Z"带 steps、expected、actual 的叙述式 bug report。
"Write a spec for..."结构化 spec:Goal / Inputs / Outputs / Edge cases / Tests。
"Add a test that..."测试描述 + acceptance criteria。
"Explain why this code..."普通说明文字,保持技术语气。

6 个完整示例

你说(Cursor,已选中一个函数)
"refactor this to use the new auth client and remove the legacy fallback that's not used anywhere else"
Loqua 写出(在 Cursor chat 中)
Refactor the selected function to use the new AuthClient. Remove the legacy fallback path — confirmed unused elsewhere in the codebase. Preserve the public function signature.
你说(在 Claude Code 里 debug)
"when I call the search endpoint with an empty query I get a 500 instead of an empty array I expected the empty case to be handled gracefully"
Loqua 写出(在 Claude Code terminal 中)
Debug: search endpoint returns 500 on empty query.

Steps:
1. POST /search with body { "query": "" }
2. Server responds 500 (expected: 200 with empty array)

Hypothesis: the empty-string path skips the early-return and hits the indexer with an invalid query.

Fix: add an early return for empty queries.
你说(为新功能写 spec)
"spec for a saved searches feature users can save a search and reload it later it should sync across devices and be queryable by name"
Loqua 写出(在 Cursor planning doc 中)
## Spec: Saved Searches

**Goal:** users save a search query and reload it later.

**Inputs:** search query (string), user id, optional name (string, defaults to first N chars of query).

**Behavior:**
- Persist to user's saved-searches collection.
- Sync across devices via existing user-data sync.
- Queryable by name (case-insensitive substring match).

**Edge cases:** duplicate names → suffix with index; deleted user → cascade delete.
你说(要求添加测试)
"add a test that verifies the rate limiter blocks the eleventh request in a one minute window and returns a 429 with a retry after header"
Loqua 写出(在 Claude Code 中)
Add a test for the rate limiter:
- Send 10 requests in a 60-second window — all succeed.
- 11th request should return 429.
- Response must include a Retry-After header with seconds-remaining value.
- Use existing test fixtures for time control.
你说(多文件重构请求)
"break the user controller into separate files for auth profile and preferences keep the existing public API and update the router"
Loqua 写出(在 Cursor chat 中)
Refactor: split userController.ts into three modules — authController, profileController, preferencesController. Keep the public API surface unchanged. Update the router to import from the new locations. No behavior changes; this is a structural refactor only.
你说(任务中途转向)
"actually before we refactor add a regression test that covers the current behavior of the merge function so we can detect drift later"
Loqua 写出(在 Claude Code 中)
Before refactoring: add a regression test covering the current behavior of the merge function. The test should snapshot the existing outputs so we can detect any drift introduced by the refactor.

让 Loqua 看到文件上下文

当你没有选中内容就说 "refactor this",Loqua 只会发送指令。当你选中了文本,Loqua 会在指令前加入一个简短的上下文块,说明选中了什么:文件名、行号、周围标识符。你不需要自己说这些上下文,多模态层会读取。

这对需要显式上下文的 AI 工具很重要,Claude Code 尤其受益于文件路径和行号。Loqua 的 omni-modal stack 正是让这件事成立的原因。如果你想看研究层面的直觉,可以读更深入的 voice meets vision: omni-modal dictation

句中 EN+中 混说

我们工程团队的很多讨论是中文夹英文技术词。用这种语域给 AI 工具做语音 prompt,是每天都会发生的事。Loqua 能在不切换模式的情况下处理中英混说:

你说(在 Cursor chat 中)
"那个 cache invalidation 的逻辑要重构 现在 race condition 太多了 边界 case 经常漏"
Loqua 写出(作为 Cursor prompt
那个 cache invalidation 的逻辑要重构 —— 现在 race condition 太多了,边界 case 经常漏。请帮我重新设计 invalidation 策略:列出 race-condition 风险点,给出建议的同步原语方案,覆盖典型边界 case。

跨工具复用

同一句语音,说进不同 AI 工具,会生成适合各自目标位置的 prompt。你不用重新组织,Loqua 会处理:

工具Loqua 生成的 prompt 形态
Cursor(聊天面板)带隐式文件上下文的对话式指令
Claude Code(终端)带显式文件路径和简短计划的结构化指令
ChatGPT(网页)带 section 的 Markdown 格式 prompt
Aider(终端)带目标路径的直接文件编辑指令

你只需要用语音说一次,Loqua 会按目标位置重塑输出。

容易踩坑的地方

  • 不要逐字符听写代码。语音适合 prompt 的自然语言部分,让 LLM 生成代码。逐字符说代码会违背这个工作流的意义。
  • 选区很重要。如果你希望 Loqua 把选中的代码作为上下文加入 prompt,先选中再说。否则它只会发送指令。
  • 长停顿会结束听写。1.5 秒的沉默会被识别为 utterance-end。如果你在句中思考,可以说一个填充词;Loqua 会在输出里去掉填充词,但用它保持录音不中断。
  • Cursor 的聊天面板状态很重要。如果面板不可见,Loqua 可能会把你的语音当成代码编辑,而不是 prompt。先打开面板。
  • 不要盲目听写生僻标识符。如果有不常见的自定义库名,可以在 Settings 的 Personal Dictionary 中添加,或者把它当成一个词来读。

整体效果是:长指令的 prompt 编写时间大约减半,而且 prompt 本身更好,因为语音会鼓励你解释意图,而不是只说改动名称。这一点比单纯速度更重要。关于更完整的 voice ai coding 模式,包括 voice prompt Cursor 流程、Claude Code dictation,以及长会话里如何少碰键盘,可以继续看上面链接的配套指南。

如果想看为什么语音适合 AI 工作的更长论述,可以读 为什么键盘不是和 AI 一起思考的好工具

常见问题

Loqua 能配合 Cursor 的聊天面板使用吗?
能。Loqua 会检测 Cursor 聊天面板是否打开,并把你的语音当作 prompt,而不是代码编辑。选中的代码(如果有)会被作为上下文加入。先打开聊天面板;否则 Loqua 可能会把听写当成代码文件编辑。
Loqua 能和 Claude Code 一起用吗?
能。Claude Code 运行在终端里,Loqua 会把它的输入框视为结构化指令上下文;合适时,输出会包含显式文件路径和简短计划。长重构叙述和 spec 草稿是最适合的场景。
我可以逐字符听写代码吗?
技术上可以,但不建议。语音适合 prompt 的自然语言部分:解释、目标、约束。让 LLM 生成代码。逐字符听写代码会违背这个工作流的目的。
Loqua 怎么判断这是 prompt 还是代码编辑?
它会读取当前 app、焦点状态和可见 UI 线索。Cursor 聊天面板打开是 prompt 信号。Claude Code 的终端是 prompt 信号。光标在 Python 文件的函数体里,则是代码编辑信号。
ChatGPT 或 Claude.ai 网页版怎么办?
Loqua 可以在任何文本输入框里工作,包括浏览器里的 prompt 输入框。当目标位置是聊天 AI 时,它会把输出组织成适合 Markdown 的分段 prompt。
Loqua 会把我的 prompt 发到云端吗?
Loqua 的语音识别和多模态上下文层在设备端运行。被输入到 Cursor 或 Claude Code 的文字,之后会由那些工具发送给它们自己的服务提供商(Anthropic、OpenAI 等);那是这些工具的网络行为,不是 Loqua 的。Loqua 会发送什么、不发送什么,可以看我们的 隐私说明

今天就试试 Loqua

免费开始。Mac 原生。由每天都在使用它的算法研究者打造。

下载

更多 Loqua 博客文章

教程
如何在 Mac 上用语音写代码:Cursor、VS Code 和 Claude Code 完整指南
效率
用语音和 AI 一起思考:为什么键盘不是合适工具
工程
语音输入中的强化学习:Loqua 语音栈里的 GRPO、DPO 与 on-policy distillation
对比
Loqua vs Typeless:面向上下文、编程和深度工作流的 Mac 原生 Typeless 替代品