Operating Colab

SKILL开发
开发 未标注权限 许可证不明确

Operate Google Colab environments via the `colab` CLI. Use when asked to create or manage GPU/TPU sessions, run Python/shell on a remote Colab VM, sync files, automate environment setup (packages, auth, Drive), or export session history.

一句话选型结论

按资料字段整理

Operating Colab是开发类的 Agent Skill,安装方式:GitHub 仓库,权限级别未标注,许可证不明确,没有现成安装命令,需按说明手动放置 SKILL.md。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发 安装方式GitHub 仓库 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 agent-skills
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

GitHub 仓库
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    按安装说明或仓库 README,把 SKILL.md 放到客户端的 skills 目录(一般一个技能一个文件夹)。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方lefant仓库 agent-skills · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式GitHub 仓库安装包 lefant/agent-skills
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 2026-09-07
正文体量10.4 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写代码与改 bug

按需求补代码、定位并修掉报错。

读仓库与生成改动

让模型读懂项目结构,再给出可落地的改动。

跑测试与排查故障

按现象排查问题,补测试用例并复跑。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 基础信息齐全,可以先按说明装一个试试。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有现成安装命令,要按安装说明或仓库 README 手动放置。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
Operating Colab当前 未标注权限 GitHub 仓库 未标注 未标注 无
技能审查员 浏览器控制 ClawHub 市场 877.9 万 OpenClaw 有
Vercel React 最佳实践 浏览器控制 GitHub 仓库 849.1 万 Codex、Claude、Cursor 有
GitHub 代码协作 联网访问 ClawHub 市场 763.3 万 OpenClaw 有
网页设计指南 联网访问 GitHub 仓库 668.6 万 Codex、Claude、Cursor 有
本体论 只读 ClawHub 市场 663.7 万 OpenClaw 有

SKILL.md 全文

10.4 KB
模型实际读到的说明书原文,来自技能仓库

Operating Google Colab

Modified for lefant/agent-skills: renamed the skill and added the following operating boundaries.

Operating boundaries

  • Ask before allocating billable compute unless the user already authorized it; do not silently switch hardware tiers. Prefer colab run without --keep for one-shot jobs.
  • Stop only sessions created for this task unless the user explicitly asks to stop an existing session. Download required outputs before stopping, then verify release with colab sessions.
  • Keep credentials, session tokens, and raw auth/debug logs private. Let the user complete browser consent, ADC login, and interactive Drive/GCP authentication.
  • Use Linux or macOS. Check colab version and command --help against this guidance before running; CLI behavior can change.
  • Report execution outcome, downloaded artifact paths, and whether the task session was released or intentionally retained.

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.

Installation

If the user does not already have the colab tool installed, it can be acquired
by running uv tool install google-colab-cli or pip install google-colab-cli.

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 new allocates a billable VM; colab stop releases 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 repl calls 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 separate colab exec commands. Build up state incrementally; don't re-import everything each call. (colab stop and colab restart-kernel are what actually reset it.)
  • Default working directory is /content. Every exec/repl/run cds there first; prefer absolute paths (/content/...) for file work. For colab ls/rm/upload/download, absolute /content/... paths work and the default ls path is content (VM root).
  • colab is fire-and-forget. Each command authenticates, does one thing, and exits. A detached background daemon (spawned by colab 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 is adc (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:
    bash 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/colaboratory
    Why all four: userinfo.email (session backend colab.research.google.com, else 401), colaboratory (RuntimeService colab.pa.googleapis.com keep-alive, else 403), openid+cloud-platform (mandated by gcloud itself; it rejects scope lists missing cloud-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) or colab whoami (hidden debug command: prints the active email, scopes, audience, and expiry). When any call 403s against colab.pa.googleapis.com, the cause is almost always a missing scope — colab whoami shows it instantly.
  • colab new pre-flights the keep-alive RPC right after allocating. If your token lacks the colaboratory scope 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 auth with CLI authentication. colab auth injects 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 "run colab auth" to fix a CLI 401/403 — that's a scope/identity problem fixed via the gcloud command above.

Workflow

Provision

  • colab new -s <name> (CPU). Add --gpu A100 or --tpu v6e1 for 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 --gpu value silently falls back to A100 (which then usually fails the next step). A 400 on colab new with an accelerator means no quota/entitlement for it on this account — fall back to --gpu T4 or 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> or cat script.py | colab exec -s <name>.
  • Notebooks: colab exec -s <name> -f nb.ipynb runs each code cell and writes results to <basename>_output.ipynb next to the input. A # @title Foo first line labels the cell in progress output.
  • Plots/images: PNG/JPEG outputs are intercepted. Use --output-image <path> on exec/repl to 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 with grep -a for a specific line. exec is faster when you don't need a real shell.
  • Never run colab repl, colab console, colab auth, or colab drivemount interactively from an agent — they expect a TTY and will hang. repl/console accept piped stdin and exit on EOF; auth/drivemount genuinely 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 + stop in one command. It provisions a fresh VM, runs the script with sys.argv and __name__ == "__main__" set like native python script.py args, then tears the VM down (unless --keep).
  • Exit codes propagate: an uncaught exception or sys.exit(N) in the script makes colab run exit non-zero (CPython semantics: sys.exit()/sys.exit(0) → 0, sys.exit(N) → N, sys.exit("msg") → 1).
  • Stream separation: colab run writes its own [colab] ... chatter to stderr and the script's output to stdout — so colab run job.py > out.txt captures only the script's stdout. (colab exec streams the script's stdout/stderr live to your stdout/stderr.)
  • Works as a shebang: #!/usr/bin/env -S colab run --gpu T4 makes a chmod +x'd .py a self-contained "rent a GPU, run, clean up" script. After editing CLI behavior, reinstall before testing shebangs — they resolve colab via $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/drive by default (interactive; not agent-runnable).
  • colab install -s <name> pkg1 pkg2 — installs via uv pip install --system, falling back to pip. Also colab install -s <name> -r requirements.txt.

Inspect & report

  • colab help (or colab help <cmd>) lists/explains commands; the listing is alphabetical.
  • colab sessions lists 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 raw response_body).
  • colab log -s <name> -o summary.ipynb exports the session as a notebook (also .md, .txt, .jsonl by 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 --open to launch it).
  • colab skill / colab readme print 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 in settings.json, history in history/*.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 --auth and --config automatically.

Recovery

  • "Session not found" / 404 / 401 on exec: the backend pruned the VM. colab exec/repl detect this and clean up local state automatically — run colab sessions and re-create with colab new.
  • Execution timeout or wedged kernel: colab restart-kernel -s <name> (keeps the VM, resets the kernel), or colab stop then colab new.
  • Keep-alive daemon died (colab log shows keep_alive_stopped reason=consecutive_4xx_errors): almost always the missing colaboratory scope — re-auth per the Authentication section.

常见问题

5 问
答案由本站依据条目字段整理
Operating Colab怎么安装?

没有现成安装命令:按安装说明或仓库 README,把 SKILL.md 放进客户端的 skills 目录(一般一个技能一个文件夹)。

Operating Colab支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

Operating Colab权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

Operating Colab收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

Operating Colab用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。