qodo-get-rules
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGet Qodo Rules Skill
获取Qodo Rules Skill
Description
描述
Fetches repository-specific coding rules from the Qodo platform API before code generation or modification tasks. Rules include security requirements, coding standards, quality guidelines, and team conventions that must be applied during code generation.
Use before any code generation or modification task when rules are not already loaded. Invoke when user asks to write, edit, refactor, or review code, or when starting implementation planning.
Skip if "Qodo Rules Loaded" already appears in conversation context
在代码生成或修改任务前,从Qodo平台API获取仓库专属的编码规则。这些规则包括安全要求、编码标准、质量指南以及代码生成过程中必须遵循的团队约定。
使用时机:当规则尚未加载时,在任何代码生成或修改任务前使用。当用户要求编写、编辑、重构或审查代码,或是开始实施规划时调用。
跳过场景:如果对话上下文已出现“Qodo Rules Loaded”,则跳过此步骤。
Workflow
工作流程
Step 1: Check if Rules Already Loaded
步骤1:检查规则是否已加载
If rules are already loaded (look for "Qodo Rules Loaded" in recent messages), skip to step 6.
如果规则已加载(查看近期消息中是否有“Qodo Rules Loaded”),则跳至步骤6。
Step 2: Verify working in a git repository
步骤2:验证当前工作环境为git仓库
- Check that the current directory is inside a git repository. If not, inform the user that a git repository is required and exit gracefully.
- Extract the repository scope from the git remote URL. If no remote is found, exit silently. If the URL cannot be parsed, inform the user and exit gracefully.
origin - Detect module-level scope: if inside a subdirectory, use it as the query scope; otherwise use repository-wide scope.
modules/*
See repository scope detection for details.
- 检查当前目录是否在git仓库内。如果不是,告知用户需要git仓库并正常退出。
- 从git的远程URL中提取仓库范围。如果未找到远程仓库,静默退出。如果URL无法解析,告知用户并正常退出。
origin - 检测模块级范围:如果当前目录在子目录下,则将其作为查询范围;否则使用仓库全局范围。
modules/*
详情请查看仓库范围检测。
Step 3: Verify Qodo Configuration
步骤3:验证Qodo配置
Check that the required Qodo configuration is present. The default location is .
~/.qodo/config.json- API key: Read from (
~/.qodo/config.jsonfield). If not found, inform the user that an API key is required and provide setup instructions, then exit gracefully.API_KEY - Environment name: Read from (
~/.qodo/config.jsonfield), withENVIRONMENT_NAMEenvironment variable taking precedence. If not found, inform the user that an API key is required and provide setup instructions, then exit gracefully.QODO_ENVIRONMENT_NAME - Request ID: Generate a UUID (e.g. via or
uuidgen) to use aspython3 -c "import uuid; print(uuid.uuid4())"for all API calls in this invocation. This correlates all page fetches for a single rules load on the platform side.request-id
检查是否存在所需的Qodo配置。默认位置为。
~/.qodo/config.json- API密钥:从的
~/.qodo/config.json字段读取。如果未找到,告知用户需要API密钥并提供设置说明,然后正常退出。API_KEY - 环境名称:从的
~/.qodo/config.json字段读取,ENVIRONMENT_NAME环境变量优先级更高。如果未找到,告知用户需要环境名称并提供设置说明,然后正常退出。QODO_ENVIRONMENT_NAME - 请求ID:生成一个UUID(例如通过或
uuidgen),作为本次调用中所有API请求的python3 -c "import uuid; print(uuid.uuid4())"。这会在平台端关联单次规则加载的所有页面请求。request-id
Step 4: Fetch Rules with Pagination
步骤4:分页获取规则
- Fetch all pages from the API (50 rules per page) until no more results are returned.
- On each page, handle HTTP errors and exit gracefully with a user-friendly message.
- Accumulate all rules across pages into a single list.
- Stop after 100 pages maximum (safety limit).
- If no rules are found after all pages, inform the user and exit gracefully.
See pagination details for the full algorithm and error handling.
- 从API获取所有页面(每页50条规则),直到没有更多结果返回。
- 处理每个页面的HTTP错误,以用户友好的消息正常退出。
- 将所有页面的规则累积到一个列表中。
- 最多获取100页(安全限制)。
- 如果所有页面都未找到规则,告知用户并正常退出。
完整算法和错误处理请查看分页详情。
Step 5: Format and Output Rules
步骤5:格式化并输出规则
- Print the "📋 Qodo Rules Loaded" header with repository scope, scope context, and total rule count.
- Group rules by severity and print each non-empty group: ERROR, WARNING, RECOMMENDATION.
- Each rule is formatted as:
- **{name}** ({category}): {description} - End output with .
---
See output format details for the exact format.
- 打印“📋 Qodo Rules Loaded”标题,包含仓库范围、范围上下文和规则总数。
- 按严重程度分组,打印每个非空分组:ERROR、WARNING、RECOMMENDATION。
- 每条规则格式为:
- **{name}** ({category}): {description} - 输出以结尾。
---
确切格式请查看输出格式详情。
Step 6: Apply Rules by Severity
步骤6:按严重程度应用规则
| Severity | Enforcement | When Skipped |
|---|---|---|
| ERROR | Must comply, non-negotiable. Add comment documenting compliance (e.g., | Explain to user and ask for guidance |
| WARNING | Should comply by default | Briefly explain why in response |
| RECOMMENDATION | Consider when appropriate | No action needed |
| 严重程度 | 执行要求 | 跳过时机 |
|---|---|---|
| ERROR | 必须遵守,无协商空间。添加注释记录合规情况(例如 | 向用户说明情况并请求指导 |
| WARNING | 默认应遵守 | 在回复中简要说明原因 |
| RECOMMENDATION | 酌情考虑 | 无需操作 |
Step 7: Report
步骤7:报告
After code generation, inform the user about rule application:
- ERROR rules applied: List which rules were followed
- WARNING rules skipped: Explain why
- No rules applicable: Inform: "No Qodo rules were applicable to this code change"
- RECOMMENDATION rules: Mention only if they influenced a design decision
代码生成完成后,向用户告知规则应用情况:
- 已应用的ERROR规则:列出遵循的规则
- 已跳过的WARNING规则:说明原因
- 无适用规则:告知用户:“本次代码变更无适用的Qodo规则”
- RECOMMENDATION规则:仅当它们影响了设计决策时才提及
How Scope Levels Work
范围层级的工作方式
Determines scope from git remote and working directory (see Step 2):
Scope Hierarchy:
- Universal () - applies everywhere
/ - Org Level () - applies to organization
/org/ - Repo Level () - applies to repository
/org/repo/ - Path Level () - applies to specific paths
/org/repo/path/
根据git远程仓库和工作目录确定范围(详见步骤2):
范围层级:
- 全局 () - 适用于所有场景
/ - 组织级 () - 适用于整个组织
/org/ - 仓库级 () - 适用于当前仓库
/org/repo/ - 路径级 () - 适用于特定路径
/org/repo/path/
Configuration
配置
See README.md for full configuration instructions, including API key setup and environment variable options.
完整配置说明请查看README.md,包括API密钥设置和环境变量选项。
Common Mistakes
常见错误
- Re-running when rules are loaded - Check for "Qodo Rules Loaded" in context first
- Missing compliance comments on ERROR rules - ERROR rules require a comment documenting compliance
- Forgetting to report when no rules apply - Always inform the user when no rules were applicable, so they know the rules system is active
- Not in git repo - Inform the user that a git repository is required and exit gracefully; do not attempt code generation
- No API key - Inform the user with setup instructions; set or create
QODO_API_KEY~/.qodo/config.json - No rules found - Inform the user; set up rules at app.qodo.ai
- 规则已加载时重复运行 - 先检查上下文中是否有“Qodo Rules Loaded”
- ERROR规则缺少合规注释 - ERROR规则需要添加注释记录合规情况
- 忘记在无适用规则时报告 - 务必告知用户无适用规则,让他们知晓规则系统处于活跃状态
- 不在git仓库内 - 告知用户需要git仓库并正常退出;不要尝试代码生成
- 缺少API密钥 - 告知用户并提供设置说明;设置或创建
QODO_API_KEY~/.qodo/config.json - 未找到规则 - 告知用户;请在app.qodo.ai设置规则