oauth-cli-coder
Seamlessly interact with AI CLI coders (Claude Code, Gemini CLI, Codex) via tmux TUI sessions.
The Problem
Many AI-powered CLI tools (like Anthropic's claude or Google's gemini CLI) are designed for interactive terminal use (TUI). When an agent harness like OpenClaw or Claude Code needs to drive these tools, they often run into issues with:
- Authentication: CLI tools use their own OAuth/browser flows. Running them via simple API calls doesn't leverage existing local credentials.
- TUI States: Startup warnings, trust dialogs, and upgrade prompts can block simple non-interactive pipes.
- Session Context: Maintaining a long-lived conversation requires a stable environment.
The Solution
oauth-cli-coder wraps these CLI tools in a tmux session.
- It starts the real CLI (e.g.
claude) in a background tmux pane. - It types into the pane as if a human was using it.
- It parses the terminal output to extract the AI's response.
- No
-crequired: It doesn't use simple command-line execution (claude -c "..."), but interacts with the full TUI environment, preserving the native user experience and OAuth context.
Installation
pip install oauth-cli-coder
Requires: tmux must be installed on your system.
Usage
Claude Code
from oauth_cli_coder import ClaudeProvider
# Starts a tmux session and launches 'claude'
coder = ClaudeProvider(model="claude-3-5-sonnet-20241022")
# Send a prompt and get the response
response = coder.ask("What is the current git status?")
print(response)
# Send a slash command
coder.slash_command("/compact")
# Cleanup
coder.close()
Gemini CLI
from oauth_cli_coder import GeminiProvider
coder = GeminiProvider()
print(coder.ask("Hello!"))
coder.close()
Command Line Interface (CLI)
oauth-cli-coder provides a CLI tool oauth-coder for easy interaction from shell scripts or agent harnesses without writing Python code.
Ask a question
oauth-coder ask claude "how's it going?" --model claude-3-5-sonnet-20241022
Run a slash command
oauth-coder slash claude /compact
Persistent Sessions
You can reuse a session across multiple CLI calls by specifying a --session-id:
oauth-coder ask claude "Analyze this repo" --session-id my-project
oauth-coder slash claude /compact --session-id my-project
Close a session
oauth-coder stop claude --session-id my-project
Advanced: TUI State Assessment
The library uses rule-based logic to get past common prompts (e.g., trust dialogs). If you have the gemini CLI installed, it can optionally use an LLM to assess complex TUI states and decide which keys to send to reach the main prompt.
Why 'OAuth'?
By running the actual CLI binary in a real terminal (tmux), the tool can access your existing OAuth tokens, browser sessions, and local configuration. This means you don't need to manage separate API keys for your automation—if you are logged in on your terminal, the library can use it.
License
MIT
Metadata
Release files for oauth-cli-coder 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| oauth_cli_coder-0.2.0.tar.gz | 6.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oauth_cli_coder-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.2 kB
Release files / oauth_cli_coder-0.2.0.tar.gz
| Download URL | oauth_cli_coder-0.2.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10e5fc3a2d2e41cbff60e053bf1b046ed739cb9e4b44251ba2ef85f5717cd964
|
|
BLAKE2b-256 checksum How to use checksums |
1de444bbde523f807bc143a8211a0e6b204733bf50826122d0a4cc2b106cdf9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.23
|
Release files / oauth_cli_coder-0.2.0-py3-none-any.whl
| Download URL | oauth_cli_coder-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8b14051e4fc325cd988093f1b1ac35cc3f3655358f2b6da5e7dc8f86cf2bfec
|
|
BLAKE2b-256 checksum How to use checksums |
f461631eaf5bbffc2bbf04522616b1cf7d028460ad4b6a1537c661b277874234
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.23
|
Security for oauth-cli-coder 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.