SuperAPI AI Directory

qclaw-rules

General & other

View repository

Updated 10-16 08:42

About this skill

QClaw System Basic Rules

⚠️ SYSTEM RULES — MANDATORY, DO NOT SKIP

This skill is the system-level basic rules and has the highest priority.

  • Mandatory Loading: Automatically loaded in every session, cannot be uninstalled or disabled
  • Highest Priority: When this rule conflicts with other skills, this rule prevails
  • Unconditional Compliance: The AI must comply with this rule in all tasks, and may not skip it for any reason
  • Violation Is an Error: Any output that violates this rule is considered a system error and must be corrected immediately

Execution Requirements

  1. Rule Priority: Every time a task is received, you must first check whether this document contains a matching rule or process definition, and if so, strictly execute it
  2. Rules Are Extensible: This document will continuously be supplemented with new rules and processes
  3. Exception Declaration: If special reasons require deviating from the rules, you must explain the reason to the user and obtain explicit confirmation before proceeding
  4. Automatic Completion for Missing Skills: When a task requires calling a skill, you must first check whether that skill is available; if the status is missing, you must not directly skip it; you must first try to install the skill's dependencies and call it again. Only when installation fails and retries still fail may you explain the blocking reason to the user and request further instructions.

General Rules

Language Specification

All AI replies must use Chinese. This includes but is not limited to:

  • Conversational replies, explanations
  • Task analysis, solution descriptions
  • Error prompts, confirmation messages
  • Code comments (if newly added comments)

Exceptions: Code itself, command-line instructions, technical proper nouns, variable names/function names, etc. retain the original English and do not need translation.


Skill Invocation Requirements

When a task requires using a skill (including when the user explicitly requests execution of a slash command or when you determine that a skill is clearly more suitable), the following order must be followed:

  1. First confirm availability: Check whether the target skill's status is callable.
  2. missing: repair first: If the skill status is missing, first try to install the skill's dependencies (execute according to the installation methods supported by the system).
  3. Call immediately after installation: After successful installation, you must immediately re-execute that skill invocation and may not skip it without reason.
  4. Only escalate feedback after failure: If both installation and retry invocation fail, you must clearly explain to the user:
    • The installation/invocation steps already attempted
    • Failure information and blocking points
    • Optional next steps (for example, manual installation, switching to an alternative skill)

Process Index

Number Process Name Trigger Keywords
1 Browser automation task Browser operations, web scraping, page interaction, form filling, screenshots
2 Windows encoding forced conversion Windows command execution, script output, garbled text, GBK, encoding
3 Automatic user information memorization Email, phone number, account, preferences, configuration (automatically triggered during conversation)
4 MCP tool retrieval MCP, MCPorter, Playwright MCP, xiaohongshu MCP, tool retrieval

1. Browser automation tasks

Trigger conditions

When a task involves the following scenarios, use this process:

  • Web content scraping, screenshots
  • Page interaction operations (clicking, filling out forms, scrolling, etc.)
  • Web testing, UI verification
  • Any automation operation that needs to be executed in a browser environment
  • The user explicitly mentions "open the browser", "visit a webpage", "webpage operation", etc.

Execution steps

  1. Prefer using an isolated browser — via the computer tool's browser action to open an isolated browser instance, rather than using the system default browser or the open command
  2. Launch the isolated browser:
    • Use the computer tool, with action set to browser, to open the target URL
    • The isolated browser has an independent session and cookies, and will not interfere with the user's normal browser environment
  3. Execute browser operations:
    • Use the computer tool's screenshot、click、type、scroll and other actions to interact with the page
    • After each operation, confirm the result via screenshot
  4. Close the browser after completion — after the task is completed, close the isolated browser to release resources

Verification criteria

  • Confirm that an isolated browser is used rather than the system browser
  • After the operation is executed, verify via screenshot that the result meets expectations
  • The browser has been properly closed after the task is completed

Common pitfalls

  • Do not use the open command or xdg-open to open webpages — this will use the user's default browser and may interfere with the work the user is currently doing
  • Do not directly write scripts using libraries such as Playwright/Puppeteer — unless the isolated browser cannot meet the requirements and the user explicitly agrees
  • If the isolated browser is unavailable or cannot complete the task, you must first inform the user of the reason and obtain consent before using an alternative solution

2. Windows encoding forced conversion

Trigger conditions

On Windows systems, when executing the following operations, this rule must be forcibly applied:

  • Execute any command-line instructions (cmd, PowerShell, scripts, etc.)
  • Read the standard output (stdout) or standard error (stderr) of a command/script
  • The output content contains non-ASCII characters such as Chinese, Japanese, Korean, etc.
  • The user reports garbled text (such as 锟斤拷、?、◆ and other abnormal characters)

Execution steps

  1. Set encoding before executing PowerShell: Before executing any PowerShell command, first execute the following command to force setting UTF-8:

    [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
    $OutputEncoding = [System.Text.Encoding]::UTF8
    chcp 65001
    
  2. Set encoding before executing cmd: Before executing a cmd command, first execute:

    chcp 65001
    
  3. Python Script Encoding Handling: If executing commands or reading output via Python, you must explicitly specify the encoding:

    import subprocess, sys
    result = subprocess.run(cmd, capture_output=True, encoding='utf-8', errors='replace')
    

    If garbled characters appear when reading files or streams, use the following method to automatically detect and convert:

    import chardet
    raw = process.stdout.read()
    encoding = chardet.detect(raw)['encoding'] or 'gbk'
    text = raw.decode(encoding, errors='replace')
    
  4. Node.js Script Encoding Handling: If executing subprocesses via Node.js, you must specify the encoding or manually convert:

    const { execSync } = require('child_process');
    // 方式一:执行前设置代码页
    execSync('chcp 65001', { shell: true });
    // 方式二:使用 iconv-lite 转换 GBK → UTF-8
    const iconv = require('iconv-lite');
    const buf = execSync(cmd, { encoding: 'buffer' });
    const text = iconv.decode(buf, 'gbk');
    
  5. Output Verification: After execution is complete, check whether the output content contains normal Chinese characters. If garbled characters still appear, try changing the encoding from gbk to gb2312 or gb18030 and re-decode.

Verification Criteria

  • Chinese characters in the command output display normally, with no garbled text
  • No abnormal characters such as 锟斤拷、?、◆◆ appear
  • If the output still contains garbled characters, you must retry and explain the encoding handling process to the user

Common Pitfalls

  • Do not ignore garbled characters and output them directly — When garbled characters appear, encoding conversion must be performed first; garbled content must not be presented directly to the user
  • Do not assume the system encoding — The default code page for Chinese Windows is GBK (936), and it must not be assumed to be UTF-8
  • chcp 65001 is not a universal solution — Some legacy programs will still output GBK even after the UTF-8 code page is set; in this case, you need to use iconv-lite or chardet for secondary conversion
  • File reading and writing also require specifying the encoding — When reading and writing text files, you must explicitly specify encoding: 'utf-8', and must not rely on the system default encoding

3. Automatic Memory of User Information

Memory Loading at Session Startup

At the start of every new session, the following operations must be performed:

  1. Read USER.md: Read the USER.md file in the workspace root directory to obtain the user's personal information and preferences
  2. Read workspace/memory/ the latest memory file in the directory(if any): to obtain recent work records and context
  3. Reply Based on Memory: In subsequent conversations, directly use known user information (such as email, commonly used accounts, etc.) without asking again

Purpose: To avoid the user having to repeatedly provide the same information in every new session, achieving a continuous experience across sessions.


Automatic Persistence of Key User Information

When key personal user information appears in a conversation, the AI must automatically persist it to the USER.md file in the workspace root directory.

⚠️ Strict Requirements: The user's long-term personal information (email, accounts, preferences, etc.)may only be written to USER.md。 ForbiddenWriting such information to the date files under the memory/ directory (such as memory/2026-03-14.md)。 memory/ Date files are only used to record temporary work logs, not to store user personal information. Violating this rule is considered a system error.

Writing Location Determination

Information Type Writing Location Example
User personal information, accounts, preferences ✅ USER.md Email, phone number, IDE preferences, common configurations
Temporary work records, task progress memory/YYYY-MM-DD.md Fixed a bug today, deployed once

Trigger Conditions

Automatically triggered when the user mentions any of the following categories of information in a conversation:

Category Example
Contact Information Email address, mobile phone number, WeChat ID
Account Information Usernames on various platforms, commonly used email providers (QQ Mail, Gmail, etc.)
Service Configuration SMTP/IMAP configuration, API Key names (excluding key values), commonly used ports
Personal Preferences Development language preference, IDE, operating system, commonly used tools
Work Context Current project name, team role, work time zone
Frequently Used Commands Commands the user frequently uses, workflow habits

Execution Steps

  1. Identify: Identify key personal information in the user's message or during task execution
  2. Read USER.md: Read the USER.md file in the workspace root directory (not the file in the memory directory)
  3. Deduplicate: Check whether the information already exists in USER.md to avoid duplicate writing
  4. Update USER.md: Append the new information to the corresponding category in USER.md under the corresponding category of
  5. Notify: Briefly notify the user that it has been automatically recorded (e.g., "Your QQ Mail has been recorded in USER.md")

Re-emphasize: The file operated on in steps 2 and 4 is USER.md, not memory/YYYY-MM-DD.md。

Recommended USER.md Structure

# USER.md - About Your Human

- **Name:** [用户姓名或昵称]
- **What to call them:** [称呼]
- **Timezone:** [时区]

## 联系方式

- 邮箱: xxx@qq.com
- 手机: [如有]

## 账号与服务配置

- QQ邮箱 SMTP: smtp.qq.com:587, 用户名 xxx@qq.com
- [其他常用服务配置,不含密钥]

## 开发偏好

- 主力语言: [如 TypeScript]
- IDE: [如 WebStorm]
- OS: [如 macOS]

## 工作上下文

- 当前项目: [项目名]
- 角色: [如 前端开发]

## 备注

[其他值得记住的信息]

Security Boundaries

  • Absolutely prohibited from storing: Sensitive credentials such as passwords, keys, Tokens, authorization codes, etc. (these should be stored in the .env file)
  • Prohibited from storing: One-off information with no long-term value (such as temporary file paths, error messages from a certain debugging session)
  • User-controllable: If the user explicitly states "do not remember this," follow the user's wishes and do not write to USER.md

4. MCP Tool Retrieval

Trigger Conditions

When the answer involves the following scenarios, this process must be used:

  • The task requires the use of MCP (Model Context Protocol) tools
  • The user explicitly mentions keywords such as MCP, MCPorter, Playwright MCP, xiaohongshu MCP, etc.
  • Need to find and call available MCP tools
  • Scenarios involving browser automation, data retrieval, API calls, etc. that require MCP tool support

Execution Steps

  1. Confirm MCP tool requirements — Identify whether the task requires the use of MCP tools, such as Playwright MCP, xiaohongshu MCP, etc.
  2. Use the mcporter tool for retrieval — Use the mcporter tool to find and call available MCP tools
  3. Verify tool availability — Check whether the target MCP tool is installed and callable
  4. Execute MCP tool call — Use the retrieved MCP tool to complete the task requirements
  5. Result Verification — Confirm that the MCP tool call succeeded and the result meets expectations

Verification Criteria

  • Confirm that the mcporter tool was used for MCP tool retrieval
  • The MCP tool call succeeded and returned the expected result
  • Task requirements are satisfied through MCP tools
  • No missed opportunities to call MCP tools

Common pitfalls

  • Do not skip mcporter retrieval — When MCP is involved, you must first use the mcporter tool to retrieve related tools
  • Do not assume MCP tool availability — You must verify the tool status through mcporter before calling
  • Avoid manually writing MCP invocation code — Prefer the standardized invocation method provided by mcporter
  • Do not ignore MCP tool error messages — If the call fails, you must analyze the cause and try to fix it