🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman
Overleaf CLI for terminal sync, Git, and MCP
olcli connects a local terminal workflow to Overleaf. You can list projects, pull and push files, keep a two-way sync, compile PDFs, and manage review comments without opening the web editor. It also plugs Overleaf into Git as a remote helper and into agent workflows through MCP. The repo’s TypeScript code is split into client, sync, diff, ignore, and remote-helper pieces, with docs for each integration.
Builders who edit LaTeX in Overleaf but want Git, terminal commands, or agent access around the same projects.
You can work on Overleaf projects locally, keep them in sync, and let agents or Git interact with them directly.
What it does
Pull, push, and bidirectional sync
Download Overleaf projects, upload local changes, or run a two-way sync with conflict handling and deletion propagation.
Git remote helper
Use Overleaf like a git remote so standard `git clone` and `git push` workflows work with Overleaf projects.
MCP server for agents
Expose Overleaf actions through Model Context Protocol so agents can list projects, sync files, and compile documents.
Compile and download PDF output
Trigger Overleaf compilation, download PDFs, and fetch build artifacts such as `.bbl`, `.log`, and `.aux`.
Comments and file management
List, add, reply to, resolve, reopen, and delete comments, plus rename, delete, upload, and download files by path.
Library API
Use `@aloth/olcli` as a TypeScript library with `OverleafClient` and exported config and ignore helpers.
How to get it
- 1Run
brew tap aloth/tap brew install olcli
- 2Run
npm install -g @aloth/olcli
- 3Or use with npx without installation
npx @aloth/olcli list
- 4Run
npx skills add aloth/olcli
- 5Session cookie (overleaf.com and self-hosted)
olcli auth --cookie "your_session_cookie_value"
- 6Email/password (self-hosted without reCAPTCHA)
olcli auth --email "you@example.com" # prompts for the password, so it stays out of your shell history
README
olcli — Overleaf CLI
Command-line interface for Overleaf — Sync, manage, and compile LaTeX projects from your terminal.
Work with Overleaf projects directly from your command line. Edit locally with your favorite editor, version control with Git, and sync seamlessly with Overleaf's cloud compilation.
Features
- 📋 List all your Overleaf projects
- ✨ Create blank or example projects
- ⬇️ Pull project files to local directory for offline editing
- ⬆️ Push local changes back to Overleaf
- 🔄 Sync bidirectionally with smart conflict detection
- 🔍 Diff local files against the live remote before pushing
- 🔀 Git remote — use Overleaf as a native git remote (docs)
- ✌️ Two-way deletions — files removed locally are deleted on Overleaf on next sync
- 🗑️ Delete and ✏️ rename remote files by path
- 🚫 Smart ignore — LaTeX build artifacts and OS noise filtered automatically; extend with
.olignore - 📄 Compile PDFs using Overleaf's remote compiler
- 📦 Download individual files or full project archives
- 📤 Upload files to projects
- 💬 Review comments — list, add, resolve, reopen, delete, and reply to threads
- 🗂️ Preserve folder structure when pushing nested files
- ⏱️ Configurable timeout for slow connections
- 🔑 Password login for self-hosted instances (no browser required)
- ⚙️ Self-hosted Overleaf/ShareLaTeX support
- 📊 Output compile artifacts (
.bbl,.log,.auxfor arXiv submissions) - 🤖 MCP server for AI assistants (docs)
Perfect for:
- Editing LaTeX in your preferred text editor (Vim, VS Code, Emacs, etc.)
- Version control with Git while using Overleaf's compiler
- Automating workflows and CI/CD pipelines
- Offline work with periodic sync
Installation
Homebrew (macOS/Linux)
brew tap aloth/tap
brew install olcli
npm (all platforms)
npm install -g @aloth/olcli
Or use with npx without installation:
npx @aloth/olcli list
For AI agents (via AgentSkills)
npx skills add aloth/olcli
Quick Start
1. Authenticate
Session cookie (overleaf.com and self-hosted):
olcli auth --cookie "your_session_cookie_value"
Email/password (self-hosted without reCAPTCHA):
olcli auth --email "you@example.com"
# prompts for the password, so it stays out of your shell history
The password is not stored unless you pass --save-password. A session
cookie is saved either way and is what later commands use; the password only
buys an automatic re-login once that cookie expires. For scripts, set
OVERLEAF_EMAIL and OVERLEAF_PASSWORD — every command reads them, so a
scripted run never needs olcli auth at all.
2. List Projects
olcli list
3. Pull, Edit, Push
olcli pull "My Thesis"
cd My_Thesis/
vim main.tex
olcli push
4. Compile PDF
olcli pdf
# Compile a specific .tex file (for multi-doc projects):
olcli pdf -r appendix.tex
5. Or use native git commands
git clone overleaf::https://www.overleaf.com/project/<id>
cd <project>
# edit, commit, push — standard git workflow
git push
See Git Remote Helper docs for details.
Commands
All commands auto-detect the project when run from a synced directory (contains .olcli.json).
| Command | Description |
|---|---|
olcli auth | Set session cookie or login with email/password |
olcli whoami | Check authentication status |
olcli logout | Clear the global config and the local .olauth, reporting each |
olcli list | List all projects |
olcli info [project] | Show project details and file list |
olcli pull [project] [dir] | Download project files to local directory |
olcli push [dir] | Upload local changes to Overleaf (--delete also removes files deleted locally) |
olcli sync [dir] | Bidirectional sync (pull + push) |
olcli diff [project] [dir] | Show content-level changes between local files and the remote |
olcli upload <file> [project] | Upload a single file (--to <path> sets the remote destination) |
olcli download <file> [project] | Download a single file |
olcli delete <file> [project] | Delete a remote file or folder (alias: rm) |
olcli rename <old> <new> [project] | Rename a remote file or folder (alias: mv) |
olcli project create <name> | Create a blank or example project (--template blank|example) |
olcli project rename <new> [project] | Rename the project itself (--dry-run) |
olcli project rename-bulk | Rename many projects by pattern (dry-run unless --apply) |
olcli compile [project] | Trigger PDF compilation |
olcli pdf [project] | Compile and download PDF |
olcli output [type] | Download compile output files |
olcli zip [project] | Download project as zip archive |
olcli comments list [project] | List comments (--status, --context) |
olcli comments add <file> <msg> | Add a comment to selected text |
olcli comments reply <id> <body> | Reply to a comment thread |
olcli comments resolve <id> | Resolve a comment thread |
olcli comments reopen <id> | Reopen a resolved thread |
olcli comments delete <id> | Delete a comment thread |
olcli ignored [dir] | List ignore patterns in effect |
olcli config set-url <url> | Set self-hosted base URL |
olcli config get-url | Show the configured base URL |
olcli config set-cookie-name <name> | Set session cookie name |
olcli config get-cookie-name | Show the configured session cookie name |
olcli config set-timeout <ms> | Set default HTTP timeout |
olcli config get-timeout | Show the configured HTTP timeout |
olcli check | Show config paths and credential sources |
Compile Options
The compile-related commands (compile, pdf, output) accept:
| Flag | Description |
|---|---|
-r, --resource <path> | Compile a specific .tex file as the root document (e.g. appendix.tex, folder/test.tex) |
Useful in multi-doc projects: each -r run compiles the file as if it were the main document.
Global Options
| Flag | Description |
|---|---|
--verbose | Print HTTP requests and responses to stderr |
--base-url <url> | Override Overleaf instance URL |
--cookie-name <name> | Override session cookie name |
--timeout <ms> | Override HTTP timeout (default: 10000) |
Sync Behavior
Pull
- Downloads all files from Overleaf
- Skips local files modified after last pull (won't overwrite your changes)
- Use
--forceto overwrite local changes
Push
- Uploads files modified after last pull
- Preserves nested folder structure
- Filters out LaTeX build artifacts and OS noise
- Use
--allto upload all files,--dry-runto preview
Sync
- Pulls remote changes, then pushes local changes
- Local modifications win if newer
- Propagates local deletions — use
--no-deleteto opt out - Use
--dry-runto preview without applying
Diff
olcli diff compares the bytes of your local files against the project's
current contents and prints a unified diff.
olcli diff # every changed file, as patches
olcli diff --name-only # just the changed paths
olcli diff --file main.tex # one file
olcli diff -U 8 # wider context
The remote side is fetched fresh on every run. The diff describes the
project as it is at that moment — which is what a subsequent push would
overwrite — not a comparison against your last pull. .olcli.json records
remote paths, never remote contents, so there is no stored snapshot to
compare against; and the whole project arrives in a single request, the same
one pull makes, so fetching fresh costs one round trip rather than one per
file. A collaborator editing between diff and push can still change the
outcome, which is why the fetch time is printed.
In the output, a/ is the remote and b/ is local: a + line is content
push would upload, a - line is content it would overwrite. Files that
differ only in bytes that are not text (PDFs, images) are reported as
Binary files ... differ. Both sides pass through the same ignore layers, so
build artifacts sitting on Overleaf are not reported as locally deleted.
diff --name-only and push --dry-run answer different questions and will
disagree. push --dry-run lists files whose modification time is newer
than the last pull, because that is what push uploads; diff lists files
whose contents actually differ. A file you touched without editing appears
in the first and not the second.
How deletion propagation works
olcli records a manifest of remote files in .olcli.json. On next sync:
- File missing locally + still on remote → deleted on Overleaf
- File new locally → uploaded
- File modified locally → uploaded (local wins)
- File only on remote → downloaded
First-time syncs skip the deletion phase (no prior manifest to compare).
Ignoring Files
Three layers
| Layer | Source | Purpose |
|---|---|---|
| 1 | Built-in | LaTeX intermediates, OS noise, build dirs. Always on. |
| 2 | .olignore | Project-level patterns (gitignore syntax). |
| 3 | .olignore.local | Machine-specific patterns. |
Later layers override earlier ones. Negation (!important.aux) is supported.
Special PDF rule
X.pdf is ignored only if X.tex (or .ltx) exists in the same folder.
Inspecting and overriding
olcli ignored # list patterns in effect
olcli push --show-ignored # see what was skipped
olcli sync --no-default-ignore # only .olignore applies
olcli sync --no-ignore # upload everything
Configuration
Credentials are checked in order:
OVERLEAF_SESSIONenvironment variable.olauthfile in current directory- Global config — run
olcli checkto see the exact path
The global config path is platform-dependent (conf resolves it), so it is not
hardcoded here: on macOS it lands under ~/Library/Preferences/, on Linux under
~/.config/. olcli auth prints the path it wrote to.
⚠️ olcli auth --save-local writes .olauth into the current directory,
which is usually your LaTeX project. Add it to that project's .gitignore
before committing.
What is stored, and how to clear it
Everything is stored in plaintext, so it is worth knowing what is on disk:
| Credential | Stored by default | Where |
|---|---|---|
| Session cookie | yes | global config, or .olauth with --save-local |
| Email + password | no — only with --save-password | global config |
olcli check reports what exists without printing any secret.
olcli logout clears the global config and the .olauth file in the
current directory, then lists what it removed. It cannot unset environment
variables, so if OVERLEAF_SESSION or OVERLEAF_EMAIL/OVERLEAF_PASSWORD are
set, it says so instead of implying you are logged out — those take precedence
over anything on disk.
Self-hosted Overleaf
olcli config set-url https://latex.example.org
olcli config set-cookie-name overleaf.sid
Or pass per-command: olcli --base-url https://latex.example.org list
Timeout
olcli config set-timeout 60000 # persist
olcli --timeout 60000 pull "Big Thesis" # one-off
export OVERLEAF_TIMEOUT=60000 # env var
Precedence: --timeout > OVERLEAF_TIMEOUT > config > default (10000ms).
Examples
# Daily thesis workflow
olcli pull "PhD Thesis" thesis && cd thesis
vim chapters/methods.tex
olcli sync && olcli pdf -o draft.pdf
# Quick PDF download
olcli pdf "Conference Paper" -o paper.pdf
# Compile a specific root document
olcli pdf "Conference Paper" -r appendix.tex -o appendix.pdf
olcli compile "Conference Paper" -r folder/test.tex
# Upload figures
olcli upload figures/diagram.png # relative path is preserved
olcli upload /tmp/build/diagram.png # absolute path lands in the project root
olcli upload /tmp/build/diagram.png --to figures/diagram.png # explicit destination
# arXiv submission prep
olcli output bbl -o main.bbl
olcli output bbl -r folder/test.tex -o main.bbl # compile artifacts from a specific root doc
olcli zip -o arxiv-submission.zip
# Backup all projects
for proj in $(olcli list --json | jq -r '.[].name'); do
olcli zip "$proj" -o "backups/${proj}.zip"
done
Programmatic Usage (Library API)
@aloth/olcli exposes OverleafClient and all public interfaces as a library.
Install
npm install @aloth/olcli
Basic example
import { OverleafClient } from '@aloth/olcli';
const client = await OverleafClient.fromSessionCookie(cookie);
const created = await client.createProject('My Paper');
const projects = await client.listProjects();
const info = await client.getProjectInfo(projectId);
const zipBuf = await client.downloadProject(projectId);
const pdfBuf = await client.downloadPdf(projectId);
await client.uploadFile(projectId, null, 'main.tex', readFileSync('main.tex'));
const comments = await client.listComments(projectId, { status: 'open' });
Available exports
import {
OverleafClient,
// Types
Project, ProjectInfo, ProjectTemplate, CreateProjectOptions, CreatedProject,
FolderEntry, DocEntry, FileEntry,
CommentMessage, ProjectComment, CommentContext, CommentStatus,
ListCommentsOptions, AddCommentOptions, Credentials, SessionCookiePair,
// Config utilities
getBaseUrl, setBaseUrl, getSessionCookie, setSessionCookie,
getSessionCookieName, setSessionCookieName, getCsrf, setCsrf,
getLastProject, setLastProject, clearConfig, getConfigPath, saveOlAuth,
getTimeout, setTimeout, getPasswordCredentials, setPasswordCredentials,
clearPasswordCredentials, type PasswordCredentials,
// Ignore utilities
DEFAULT_IGNORE_PATTERNS, loadIgnore, shouldIgnore, buildTexSiblingSet,
IgnoreContext, LoadIgnoreOptions,
} from '@aloth/olcli';
Further Documentation
- MCP Server — AI assistant integration (Claude, Cursor, Windsurf)
- Git Remote Helper — use Overleaf as a native git remote
Troubleshooting
Session expired — Get a fresh cookie from the browser and run olcli auth again.
Compilation fails — Check the Overleaf web editor for detailed error logs (missing packages, syntax errors, missing bibliography files).
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
See CONTRIBUTING.md for local setup, which tests need a real Overleaf account, and what to expect from CI on a pull request.
docs/ARCHITECTURE.md explains how the client works — there is no public Overleaf API, so it authenticates as a browser session.
License
MIT © Alexander Loth
Files in the repo
- .github
- docs
- screenshots
- src
- test
- .gitignore
- .npmignore
- CHANGELOG.md
- CITATION.cff
- CONTRIBUTING.md
- eslint.config.js
- flake.nix
- LICENSE
- package-lock.json
- package.json
- README.md
- SECURITY.md
- SKILL.md
- tsconfig.json
Discussion (0)
Ask about usage, or say what you built with itSign in to join the discussion.
No comments yet. Be the first to say what this is good for.
More tools
The best-benchmarked open-source AI memory system. And it's free.
Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io
Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors
Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.