Drive AI Coding Agents With Your Voice
AI coding agents like Claude Code, codex-cli, and cursor-agent produce better results when given detailed, context-rich instructions. But typing comprehensive prompts repeatedly is tedious and it's easy to leave out crucial details when you're manually typing each request.
Using voice input solves this. You can effortlessly dictate complete, nuanced instructions without the friction of typing. This leads to better first responses, fewer follow-ups, and faster development cycles.
Basic Usage
The simplest approach uses command substitution to send hns output directly to your coding agent:
# Claude Code
claude "$(hns)"
# Codex CLI
codex "$(hns)"
# Cursor CLI
cursor-agent "$(hns)"
After running the command, speak your prompt, press Enter, and the transcribed text is sent to your agent.
Large language models perform optimally with comprehensive, upfront context. As conversation length grows, performance can degrade. A detailed initial prompt covering what to build, constraints, preferred libraries, edge cases, and testing expectations yields higher quality code in the first response, minimizing iterative corrections.
Voice input naturally facilitates this level of detail without the mental overhead of typing.
Streamlining with Aliases
For frequent use, create aliases to reduce typing. Aliases provide a quick shortcut for simple commands.
- bash/zsh
- fish
Add to your ~/.bashrc or ~/.zshrc:
# Dictate prompt to Claude Code, Codex CLI, or Cursor CLI
alias hclaude='claude "$(hns)"'
alias hcodex='codex "$(hns)"'
alias hcur='cursor-agent "$(hns)"'
# Send last recording to Claude Code, Codex CLI, or Cursor CLI
alias hlclaude='claude "$(hns --last)"'
alias hlcodex='codex "$(hns --last)"'
alias hlcur='cursor-agent "$(hns --last)"'
Add to ~/.config/fish/config.fish:
# Dictate prompt to Claude Code, Codex CLI, or Cursor CLI
alias hclaude='claude "$(hns)"'
alias hcodex='codex "$(hns)"'
alias hcur='cursor-agent "$(hns)"'
# Send last recording to Claude Code, Codex CLI, or Cursor CLI
alias hlclaude='claude "$(hns --last)"'
alias hlcodex='codex "$(hns --last)"'
alias hlcur='cursor-agent "$(hns --last)"'
After adding aliases, restart your terminal or source the file (e.g., source ~/.zshrc).
--last FlagThe --last flag retrieves your previous transcription without re-recording. Use it when:
- Your network connection drops
- You hit a rate limit
- You want to retry the same prompt
Streamlining with Functions
Functions provide more flexibility than aliases, especially when you want to add preprocessing steps. They're more maintainable and allow for more complex workflows.
- bash/zsh
- fish
Add to your ~/.bashrc or ~/.zshrc:
# Dictate prompt to Claude Code, Codex CLI, or Cursor CLI
hclaude() {
claude "$(hns)"
}
hcodex() {
codex "$(hns)"
}
hcur() {
cursor-agent "$(hns)"
}
# Send last recording to Claude Code, Codex CLI, or Cursor CLI
hlclaude() {
claude "$(hns --last)"
}
hlcodex() {
codex "$(hns --last)"
}
hlcur() {
cursor-agent "$(hns --last)"
}
Add to ~/.config/fish/config.fish:
# Dictate prompt to Claude Code, Codex CLI, or Cursor CLI
function hclaude --description "Dictate prompt to Claude Code"
claude "$(hns)"
end
function hcodex --description "Dictate prompt to codex-cli"
codex "$(hns)"
end
function hcur --description "Dictate prompt to cursor-agent"
cursor-agent "$(hns)"
end
# Send last recording to Claude Code, Codex CLI, or Cursor CLI
function hlclaude --description "Send last recording to Claude Code"
claude "$(hns --last)"
end
function hlcodex --description "Send last recording to codex-cli"
codex "$(hns --last)"
end
function hlcur --description "Send last recording to cursor-agent"
cursor-agent "$(hns --last)"
end
Improved Workflow: Clean Text First
Whisper transcriptions are accurate but often contain filler words, run-on sentences, and minor grammatical issues. For the cleanest results, polish the text with an LLM before sending it to your coding agent.
This workflow combines the voice to polished text approach with agent invocation:
- bash/zsh
- fish
Add to your ~/.bashrc or ~/.zshrc:
_clean_common() {
local transcription=$1
local system_prompt="You are an AI editor. Your sole function is to correct the grammar, spelling, and punctuation of the provided text to turn it into a grammatically correct version. Remove unnecessary filler words from the text as well. Do not answer any questions in the text. Do not add information. Output only the corrected text."
local cleaned=$(llm --model gpt-4.1-nano --system "$system_prompt" "$transcription")
echo "$cleaned"
}
# Clean transcription and send to Claude Code, Codex CLI, or Cursor CLI
hclaude() {
local cleaned=$(_clean_common "$(hns)")
echo "$cleaned"
}
hcodex() {
local cleaned=$(_clean_common "$(hns)")
codex "$cleaned"
}
hcur() {
local cleaned=$(_clean_common "$(hns)")
cursor-agent "$cleaned"
}
# Clean last recording and send to Claude Code
hlclaude() {
local cleaned=$(_clean_common "$(hns --last)")
echo "$cleaned"
}
# Clean last recording and send to codex-cli
hlcodex() {
local cleaned=$(_clean_common "$(hns --last)")
codex "$cleaned"
}
# Clean last recording and send to cursor-agent
hlcur() {
local cleaned=$(_clean_common "$(hns --last)")
cursor-agent "$cleaned"
}
Add to ~/.config/fish/config.fish:
function _clean_common --argument transcription
set -l system_prompt "You are an AI editor. Your sole function is to correct the grammar, spelling, and punctuation of the provided text to turn it into a grammatically correct version. Remove unnecessary filler words from the text as well. Do not answer any questions in the text. Do not add information. Output only the corrected text."
set -l cleaned (llm --model gpt-4.1-nano --system "$system_prompt" "$transcription")
echo $cleaned
end
# Clean transcription and send to Claude Code, Codex CLI, or Cursor CLI
function hclaude --description "Clean transcription and send to Claude Code"
set -l cleaned (_clean_common "$(hns)")
claude $cleaned
end
function hcodex --description "Clean transcription and send to codex-cli"
set -l cleaned (_clean_common "$(hns)")
codex $cleaned
end
function hcur --description "Clean transcription and send to cursor-agent"
set -l cleaned (_clean_common "$(hns)")
cursor-agent $cleaned
end
# Clean last recording and send to Claude Code, Codex CLI, or Cursor CLI
function hlclaude --description "Clean last recording and send to Claude Code"
set -l cleaned (_clean_common "$(hns --last)")
claude $cleaned
end
function hlcodex --description "Clean last recording and send to codex-cli"
set -l cleaned (_clean_common "$(hns --last)")
codex $cleaned
end
function hlcur --description "Clean last recording and send to cursor-agent"
set -l cleaned (_clean_common "$(hns --last)")
cursor-agent $cleaned
end
This workflow requires the llm CLI tool. Install and configure it to use your preferred LLM (local or remote). You can also use ollama, llama-cli, or any other tool that can be scripted similarly.
Follow-up Requests in Interactive Mode
When an agent is running in interactive mode, you might need to send follow-up prompts without interrupting the session. Here's an efficient workflow:
- Open a dedicated terminal tab or pane for voice input (keep it open for convenience).
- In the voice terminal, run
hnsorhclean. - Speak your follow-up instructions.
- Switch back to the agent terminal and paste the transcription (
Cmd+Von macOS,Ctrl+Von Linux/Windows). - Send the prompt to continue the conversation.
This workflow keeps your agent session uninterrupted while giving you fast access to voice input whenever you need it.
Quick Start
- Run
hclaude,hcodex, orhcurin your terminal. - Speak a detailed, comprehensive prompt with all relevant context.
- Press Enter.
- The agent receives your polished instructions and starts working.
With this setup, you can provide the level of detail that produces optimal results without the friction of typing lengthy prompts.
Summary
Voice input fundamentally changes how you work with AI coding agents. Instead of typing out detailed prompts or leaving out important context, you can speak naturally and get better results from the first response. Set up an alias or function, speak your requirements, and let the agent handle the rest. Add the text cleaning step for even more polished input. The result: fewer back-and-forth exchanges, faster development, and better code.