Jules CLI Skill
Overview
This skill enables the agent to interact with the
jules CLI. It supports task assignment, session monitoring, and result integration.
Usage Guidelines (CRITICAL)
To prevent excessive and inappropriate session creation, you must follow these rules:
- 1. Local First: If you can solve the task locally within your current environment (e.g., editing files, running tests, small refactors), do not use Jules.
- Complexity Threshold: Only use Jules for tasks that are:
*
Large-scale: Touching many files or requiring significant architectural changes.
*
Isolated: Benefiting from a clean, remote environment to avoid local dependency issues.
*
Exploratory: Tasks where the solution isn't immediately obvious and requires iteration in a VM.
- 3. No Proliferation (One at a Time):
*
Never create multiple sessions for the same task.
*
Never use a loop or parallel execution to spin up several sessions at once.
* Wait for a session to complete and inspect the results before deciding if another session is needed.
- 4. No "Small" Tasks: Do not submit tasks like "Add a comment", "Change a variable name", or "Fix a typo".
Security Guidelines
To ensure safe execution of CLI commands, you must adhere to the following security practices:
- 1. Input Validation: Before running any command, validate that:
*
Repository names follow the
owner/repo format (alphanumeric, dots, hyphens, and underscores).
*
Session IDs are alphanumeric (typically hyphens and underscores are also allowed).
- 2. Quoting: Always wrap shell placeholders in double quotes (e.g.,
"<repo>"). - No Inline Injection: Never embed user-provided data directly into script strings (like
python3 -c). Use environment variables to pass such data safely. - Sanitization: Ensure task descriptions do not contain malicious shell characters if passed directly to the shell.
Safety Controls
- * Approval Required (MANDATORY): You must ask for explicit user approval before running any of the following commands:
*
jules remote new: Since this creates a remote session/VM.
*
jules remote pull --apply: Since this modifies the local codebase.
*
jules teleport: Since this clones and modifies the environment.
- Verification: Always run
jules remote list --session before creating a new one to ensure you don't already have a pending session for the same repository. - Credentials: If
jules login is required, explain why* to the user and wait for their confirmation before proceeding.
Core Workflow (Manual Control)
Prefer using the CLI directly to maintain situational awareness.
1. Pre-flight Check
Verify repository access and format.
jules remote list --repo
Note: Ensure the repo format is GITHUB_USERNAME/REPO.
2. Submit Task
Create a session and capture the Session ID.
CODEBLOCK1
3. Monitor Progress
List sessions and look for your ID. Use this robust one-liner to check the status (it handles statuses with spaces like "In Progress"):
Check Status (Safe Method):
CODEBLOCK2
4. Integrate Results
Once the status is
Completed, pull and apply the changes.
# Replace <SESSION_ID> with the validated Session ID
jules remote pull --session "<SESSION_ID>" --apply < /dev/null
Error Handling & Troubleshooting
- * Repository Not Found: Verify format with
jules remote list --repo. It must match the GitHub path. - TTY Errors: Always use
< /dev/null for non-interactive automation with the raw jules command. - Credentials: If you see login errors, ensure
HOME is set correctly or run jules login.
Command Reference
| Command | Purpose |
|---|
| INLINECODE15 | Verify available repositories and their exact names. |
| INLINECODE16 |
List active and past sessions to check status. |
|
jules remote new | Create a new coding task. |
|
jules remote pull | Apply changes from a completed session. |
|
jules teleport "<id>" | Clone and apply changes (useful for fresh environments). |
Jules CLI 技能
概述
该技能使智能体能够与 jules CLI 进行交互。支持任务分配、会话监控和结果集成。
使用指南(关键)
为防止过度和不恰当的会话创建,你必须遵循以下规则:
- 1. 本地优先:如果你能在当前环境中本地解决任务(例如编辑文件、运行测试、小型重构),不要使用 Jules。
- 复杂度阈值:仅对以下类型的任务使用 Jules:
*
大规模:涉及多个文件或需要重大架构变更。
*
隔离型:受益于干净的远程环境,避免本地依赖问题。
*
探索型:解决方案不明确,需要在虚拟机中迭代的任务。
- 3. 禁止扩散(一次一个):
*
切勿为同一任务创建多个会话。
*
切勿使用循环或并行执行同时启动多个会话。
* 等待一个会话完成并检查结果后,再决定是否需要另一个会话。
- 4. 禁止小任务:不要提交诸如添加注释、更改变量名或修复拼写错误之类的任务。
安全指南
为确保 CLI 命令的安全执行,你必须遵守以下安全实践:
- 1. 输入验证:在运行任何命令之前,验证:
*
仓库名称符合 owner/repo 格式(字母数字、点号、连字符和下划线)。
*
会话 ID 为字母数字(通常也允许连字符和下划线)。
- 2. 引号使用:始终将 shell 占位符用双引号包裹(例如 )。
- 禁止内联注入:切勿将用户提供的数据直接嵌入脚本字符串(如 python3 -c)。使用环境变量安全地传递此类数据。
- 清理处理:如果任务描述直接传递给 shell,确保其中不包含恶意的 shell 字符。
安全控制
- * 需要审批(强制):在运行以下任何命令之前,你必须请求用户的明确批准:
* jules remote new:因为这会创建远程会话/虚拟机。
* jules remote pull --apply:因为这会修改本地代码库。
* jules teleport:因为这会克隆并修改环境。
- 验证:在创建新会话之前,始终运行 jules remote list --session 以确保你还没有同一仓库的待处理会话。
- 凭据:如果需要 jules login,向用户解释原因*,并在继续之前等待他们的确认。
核心工作流程(手动控制)
优先直接使用 CLI 以保持态势感知。
1. 预检检查
验证仓库访问权限和格式。
bash
jules remote list --repo
注意:确保仓库格式为 GITHUB_USERNAME/REPO。
2. 提交任务
创建会话并捕获会话 ID。
bash
捕获输出以获取 ID
将 和任务描述替换为经过验证的输入
jules remote new --repo
--session 详细的任务描述 < /dev/null
3. 监控进度
列出会话并查找你的 ID。使用这个健壮的单行命令检查状态(它能处理包含空格的状态,如In Progress):
检查状态(安全方法):
bash
使用环境变量安全地将会话 ID 传递给 Python
export JULESSESSIONID=
jules remote list --session | python3 -c
import sys, re, os
sessionid = os.environ.get(JULESSESSION_ID, )
if not session_id: sys.exit(0)
for line in sys.stdin:
line = line.strip()
if line.startswith(session_id):
# 提取状态(多个空格后的最后一列)
print(re.split(r\s{2,}, line)[-1])
unset JULESSESSIONID
4. 集成结果
一旦状态变为 Completed,拉取并应用更改。
bash
将 替换为经过验证的会话 ID
jules remote pull --session --apply < /dev/null
错误处理与故障排除
- * 仓库未找到:使用 jules remote list --repo 验证格式。必须与 GitHub 路径匹配。
- TTY 错误:在使用原始 jules 命令进行非交互式自动化时,始终使用 < /dev/null。
- 凭据:如果看到登录错误,确保 HOME 设置正确,或运行 jules login。
命令参考
| 命令 | 用途 |
|---|
| jules remote list --repo | 验证可用仓库及其确切名称。 |
| jules remote list --session |
列出活动会话和过往会话以检查状态。 |
| jules remote new | 创建新的编码任务。 |
| jules remote pull | 从已完成的会话应用更改。 |
| jules teleport | 克隆并应用更改(适用于全新环境)。 |