colab-session-operator▌
googlecolab/google-colab-cli · updated Jun 9, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Operate Google Colab environments via the colab CLI for efficient session management.
Skill: Colab Session Operator
Operate Google Colab environments via the colab CLI: provision GPU/TPU sessions, run Python/shell on the VM, sync files, and capture work as notebooks.
When to activate
- Creating or managing TPU/GPU sessions.
- Running Python or shell on a remote Colab VM.
- Syncing files between local and remote.
- Automating environment setup (packages, auth, Drive).
- Exporting session history as a Jupyter notebook.
Mental model (read this first)
- A session == a live Jupyter kernel on a rented VM.
colab newallocates a billable VM;colab stopreleases it. Nothing reclaims it automatically except a 24h keep-alive cap, so an unstopped session burns compute units indefinitely. - Kernel state PERSISTS across
colab exec/colab replcalls in the same session. Each invocation reattaches to the same kernel (the kernel ID is cached in local state) and only closes the websocket on exit — it does not shut the kernel down. So imports, variables, and defined functions survive between separatecolab execcommands. Build up state incrementally; don't re-import everything each call. (colab stopandcolab restart-kernelare what actually reset it.) - Default working directory is
/content. Everyexec/repl/runcds there first; prefer absolute paths (/content/...) for file work. Forcolab ls/rm/upload/download, absolute/content/...paths work and the defaultlspath iscontent(VM root). colabis fire-and-forget. Each command authenticates, does one thing, and exits. A detached background daemon (spawned bycolab new) handles keep-alive; you don't manage it.
Authentication (the #1 thing that blocks agents)
- The global flag is
--auth={adc,oauth2}and the default isadc(Application Default Credentials). It must come before the subcommand:colab --auth=adc new -s x. - ADC setup (most reliable for headless/agent use). The Colab backends need a specific scope set, so re-mint ADC with all four scopes:
Why all four:gcloud auth application-default login \ --scopes=openid,\ https://www.googleapis.com/auth/cloud-platform,\ https://www.googleapis.com/auth/userinfo.email,\ https://www.googleapis.com/auth/colaboratoryuserinfo.email(session backendcolab.research.google.com, else 401),colaboratory(RuntimeServicecolab.pa.googleapis.comkeep-alive, else 403),openid+cloud-platform(mandated by gcloud itself; it rejects scope lists missingcloud-platform). - oauth2 setup:
colab --auth=oauth2 <anything>triggers a browser consent flow on first use (token cached at~/.config/colab-cli/token.json). Requires a client config at~/.colab-cli-oauth-config.json(or-c PATH). The browser step means it usually needs a human; prefer ADC for agents. - Verify auth in one shot:
colab sessions(read-only, lists server assignments) orcolab whoami(hidden debug command: prints the active email, scopes, audience, and expiry). When any call 403s againstcolab.pa.googleapis.com, the cause is almost always a missing scope —colab whoamishows it instantly. colab newpre-flights the keep-alive RPC right after allocating. If your token lacks thecolaboratoryscope it unassigns the fresh VM (so you don't leak a billable assignment) and prints the exact remediation. Follow that message rather than retrying blindly.- Do NOT confuse
colab authwith CLI authentication.colab authinjects VM-side GCP credentials into the running kernel (so notebook code can call BigQuery/GCS); it is orthogonal to how the CLI itself authenticates. Never suggest "runcolab auth" to fix a CLI 401/403 — that's a scope/identity problem fixed via thegcloudcommand above.
Workflow
Provision
colab new -s <name>(CPU). Add--gpu A100or--tpu v6e1for accelerators. Always pass-s <name>— an omitted name is auto-generated as a random 6-hex string, which makes later commands ambiguous.- Supported
--gpu:T4,L4,G4,H100,A100. Supported--tpu:v5e1,v6e1. - Gotcha: an unrecognized
--gpuvalue silently falls back to A100 (which then usually fails the next step). A400oncolab newwith an accelerator means no quota/entitlement for it on this account — fall back to--gpu T4or omit the flag for CPU. - Accelerator availability is tier-gated; most accounts can only get CPU. Don't assume a GPU/TPU will allocate.
Execute
- Preferred:
colab exec -s <name> -f <script.py>runs a local script on the remote VM (read locally, sent to the kernel — no manual upload needed). - Piped code:
echo "print(1)" | colab exec -s <name>orcat script.py | colab exec -s <name>. - Notebooks:
colab exec -s <name> -f nb.ipynbruns each code cell and writes results to<basename>_output.ipynbnext to the input. A# @title Foofirst line labels the cell in progress output. - Plots/images: PNG/JPEG outputs are intercepted. Use
--output-image <path>onexec/replto save to a known location (otherwise a temp path is printed). Inline terminal-image escapes are auto-suppressed when stdout isn't a TTY, so piped/captured output stays clean. - Shell:
echo "cmd" | colab console -s <name>for batch shell. Console wraps bash in tmux, so even piped output contains terminal-control bytes — filter withgrep -afor a specific line.execis faster when you don't need a real shell. - Never run
colab repl,colab console,colab auth, orcolab drivemountinteractively from an agent — they expect a TTY and will hang.repl/consoleaccept piped stdin and exit on EOF;auth/drivemountgenuinely require a human at the terminal.
Ephemeral one-shot jobs (colab run)
colab run [--gpu T4] [--tpu v6e1] [--keep] [-s NAME] script.py [args...]=new+exec+stopin one command. It provisions a fresh VM, runs the script withsys.argvand__name__ == "__main__"set like nativepython script.py args, then tears the VM down (unless--keep).- Exit codes propagate: an uncaught exception or
sys.exit(N)in the script makescolab runexit non-zero (CPython semantics:sys.exit()/sys.exit(0)→ 0,sys.exit(N)→ N,sys.exit("msg")→ 1). - Stream separation:
colab runwrites its own[colab] ...chatter to stderr and the script's output to stdout — socolab run job.py > out.txtcaptures only the script's stdout. (colab execstreams the script's stdout/stderr live to your stdout/stderr.) - Works as a shebang:
#!/usr/bin/env -S colab run --gpu T4makes achmod +x'd.pya self-contained "rent a GPU, run, clean up" script. After editing CLI behavior, reinstall before testing shebangs — they resolvecolabvia$PATH, not the editable install. - A nonexistent script path exits non-zero before allocating a VM (no wasted compute).
Automate
colab auth -s <name>— VM-side GCP creds, needed before in-VM GCS/BigQuery calls (interactive; not agent-runnable).colab drivemount -s <name> [PATH]— mounts Drive at/content/driveby default (interactive; not agent-runnable).colab install -s <name> pkg1 pkg2— installs viauv pip install --system, falling back topip. Alsocolab install -s <name> -r requirements.txt.
Inspect & report
colab help(orcolab help <cmd>) lists/explains commands; the listing is alphabetical.colab sessionslists server-side assignments and auto-prunes stale local entries. Orphans with no local record show as[?].colab status [-s <name>]shows hardware, IDLE/BUSY, and last execution.colab log -s <name> [-n 20] [-t TYPE]shows recent structured events; invaluable when a task fails (keep-alive errors carry the rawresponse_body).colab log -s <name> -o summary.ipynbexports the session as a notebook (also.md,.txt,.jsonlby suffix).colab url -s <name>prints a browser URL that attaches the Colab web UI to your existing CLI session instead of allocating a new VM (add--opento launch it).colab skill/colab readmeprint this skill and the README (handy for self-discovery).
Safety
- Always
colab stop -s <name>when done — idle VMs burn compute units.colab run(without--keep) self-cleans even if the script errors. - Local state lives in
~/.config/colab-cli/sessions.json(settings insettings.json, history inhistory/*.jsonl). Don't edit by hand. - Isolate parallel/agent runs with the global
--config <path>flag to point session state at a scratch file (e.g.colab --config /tmp/agent.json new -s job). The keep-alive daemon inherits--authand--configautomatically.
Recovery
- "Session not found" / 404 / 401 on exec: the backend pruned the VM.
colab exec/repldetect this and clean up local state automatically — runcolab sessionsand re-create withcolab new. - Execution timeout or wedged kernel:
colab restart-kernel -s <name>(keeps the VM, resets the kernel), orcolab stopthencolab new. - Keep-alive daemon died (
colab logshowskeep_alive_stopped reason=consecutive_4xx_errors): almost always the missingcolaboratoryscope — re-auth per the Authentication section.
https://github.com/googlecolab/google-colab-cli/blob/main/COLAB_SKILL.md
How to use colab-session-operator on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add colab-session-operator
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches colab-session-operator from GitHub repository googlecolab/google-colab-cli and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate colab-session-operator. Access the skill through slash commands (e.g., /colab-session-operator) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
User Story & Requirements Generation
Create detailed user stories, acceptance criteria, and feature specs
Example
Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios
Reduce spec writing time by 50%, ensure comprehensive coverage
Competitive Analysis
Research competitors, compare features, identify gaps
Example
Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities
Complete competitive research in 2 hours instead of 2 days
Roadmap Prioritization
Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs
Example
Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale
Make data-driven prioritization decisions faster
Stakeholder Communication
Draft PRDs, status updates, and stakeholder presentations
Example
Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement
Save 3-5 hours/week on communication overhead
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client
- ›Access to product documentation and roadmap tools (Jira, Notion, etc.)
- ›Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
- ›Stakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Installation Steps
- 1.Install product management skill
- 2.Start with user story generation for known feature
- 3.Progress to competitive analysis: research 2-3 competitors
- 4.Use for roadmap prioritization: apply RICE/ICE scoring
- 5.Draft stakeholder communications and refine based on feedback
- 6.Build template library for recurring PM tasks
- 7.Share effective prompts with product team
Common Pitfalls
- ⚠Not validating competitive research—verify facts before sharing
- ⚠Accepting user stories without involving engineering team
- ⚠Over-relying on frameworks without qualitative judgment
- ⚠Not customizing outputs to company culture and communication style
- ⚠Skipping stakeholder validation of generated requirements
Best Practices▌
✓ Do
- +Validate research and competitive analysis with real data
- +Collaborate with engineering when generating technical requirements
- +Customize frameworks and templates to your company context
- +Use skill for first drafts, refine with stakeholder input
- +Document successful prompt patterns for PM tasks
- +Combine AI efficiency with human judgment and intuition
✗ Don't
- −Don't publish competitive analysis without fact-checking
- −Don't finalize user stories without engineering review
- −Don't make prioritization decisions solely on AI scoring
- −Don't skip customer validation of generated requirements
- −Don't ignore company-specific context and culture
💡 Pro Tips
- ★Provide context: company goals, constraints, customer feedback
- ★Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
- ★Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
- ★Use skill for 70% generation + 30% customization to company needs
When to Use This▌
✓ Use When
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
✗ Avoid When
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path▌
- 1Basic: user stories, feature specs, status updates
- 2Intermediate: competitive analysis, prioritization frameworks, PRDs
- 3Advanced: product strategy, go-to-market planning, OKR setting
- 4Expert: product vision, market positioning, business model innovation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.6★★★★★53 reviews- ★★★★★Neel Singh· Dec 24, 2024
I recommend colab-session-operator for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Mei Gill· Dec 16, 2024
Useful defaults in colab-session-operator — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Kabir Kim· Dec 8, 2024
colab-session-operator reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Chaitanya Patil· Dec 4, 2024
colab-session-operator reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Kaira Lopez· Nov 27, 2024
I recommend colab-session-operator for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Piyush G· Nov 23, 2024
I recommend colab-session-operator for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Diego Thomas· Nov 15, 2024
colab-session-operator reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Daniel Sharma· Nov 7, 2024
Registry listing for colab-session-operator matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Ren Dixit· Oct 26, 2024
colab-session-operator reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Kiara Srinivasan· Oct 18, 2024
Useful defaults in colab-session-operator — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
showing 1-10 of 53