Skip to content

Commit d434935

Browse files
authored
Merge pull request #19 from lvzhaobo/feat/add-generate-qoder-hooks
feat: add generate-qoder-hooks skill (en + zh)
2 parents 04b6143 + b01becb commit d434935

2 files changed

Lines changed: 136 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
name: generate-qoder-hooks
3+
title: 生成 Qoder Hooks 命令拦截
4+
description: 交互式生成 Qoder Hooks 命令拦截脚本。支持基础安全、金融合规、Workshop 教学等预设模板和自定义模式,内置审计日志记录。
5+
source: community
6+
author: Lv Zhaobo
7+
githubUrl: https://github.com/lvzhaobo/ai-coding-skills/tree/main/skills/generate-qoder-hooks
8+
category: security
9+
tags:
10+
- 命令拦截
11+
- 安全策略
12+
- Hooks
13+
- 审计日志
14+
- Qoder配置
15+
- DevOps
16+
roles:
17+
- developer
18+
- architect
19+
featured: false
20+
popular: false
21+
isOfficial: false
22+
installCommand: |
23+
git clone https://github.com/lvzhaobo/ai-coding-skills
24+
cp -r ai-coding-skills/skills/generate-qoder-hooks ~/.qoder/skills/
25+
date: 2026-04-11
26+
---
27+
28+
## 使用场景
29+
30+
- 新项目初始化命令安全策略
31+
- 定制命令黑名单(如禁止 `rm -rf``DROP TABLE``git push --force`
32+
- Workshop/培训场景演示 Hooks 拦截机制
33+
- 添加金融合规命令过滤规则
34+
- 生成跨平台脚本(Shell + PowerShell)
35+
36+
## 核心能力
37+
38+
- **4 种预设场景**:基础安全、金融合规、Workshop 教学、自定义
39+
- **交互式问答**:收集拦截模式和脚本类型偏好
40+
- **双脚本输出**:Shell (.sh) 和 PowerShell (.ps1) 模板
41+
- **审计日志**:被拦截命令记录时间戳和规则名称
42+
- **settings.json 集成**:自动更新 `hooks.before_run_command` 配置
43+
- **安全设计**:脚本仅做模式匹配,绝不执行命令本身
44+
45+
## 示例
46+
47+
```
48+
用户:帮我配置项目的命令拦截
49+
50+
Agent:选择安全场景?
51+
→ 基础安全(rm -rf、git push --force、DROP TABLE 等)
52+
53+
脚本类型?
54+
→ 跨平台(Shell + PowerShell)
55+
56+
[生成 .qoder/hooks/block-dangerous.sh + .ps1]
57+
[更新 .qoder/settings.json]
58+
59+
✅ Hooks 已生成!试试执行被拦截的命令来验证效果。
60+
```
61+
62+
## 注意事项
63+
64+
- 纯知识型 SKILL,生成脚本和配置文件,不调用外部 API
65+
- Hook 脚本使用 `exit 0`(通过)或 `exit 2`(阻断),不允许其他退出码
66+
- 脚本通过 stdin 读取 Qoder JSON 输入,用 `jq` 提取命令
67+
- 只读安全命令(`ls``cat``git status`)永远不会被拦截
68+
- 已有 settings.json 配置会被保留,新 Hook 以追加方式添加
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
name: generate-qoder-hooks
3+
title: Generate Qoder Hooks
4+
description: Interactively generate Qoder Hooks command interception scripts. Supports preset security templates (basic, financial compliance, workshop) and custom patterns with audit logging.
5+
source: community
6+
author: Lv Zhaobo
7+
githubUrl: https://github.com/lvzhaobo/ai-coding-skills/tree/main/skills/generate-qoder-hooks
8+
category: security
9+
tags:
10+
- hooks
11+
- command-filter
12+
- security
13+
- audit
14+
- qoder-config
15+
- devops
16+
roles:
17+
- developer
18+
- architect
19+
featured: false
20+
popular: false
21+
isOfficial: false
22+
installCommand: |
23+
git clone https://github.com/lvzhaobo/ai-coding-skills
24+
cp -r ai-coding-skills/skills/generate-qoder-hooks ~/.qoder/skills/
25+
date: 2026-04-11
26+
---
27+
28+
## Use Cases
29+
30+
- Set up command security policies for new projects
31+
- Customize command blocklists (e.g., block `rm -rf`, `DROP TABLE`, `git push --force`)
32+
- Demonstrate Hooks interception in workshops/training
33+
- Add financial compliance command filtering rules
34+
- Generate cross-platform scripts (Shell + PowerShell)
35+
36+
## Core Capabilities
37+
38+
- **4 Preset Scenarios**: Basic Security, Financial Compliance, Workshop, Custom
39+
- **Interactive Q&A**: Collects interception patterns and script type preferences
40+
- **Dual Script Output**: Shell (.sh) and PowerShell (.ps1) templates
41+
- **Audit Logging**: Blocked commands logged with timestamp and rule name
42+
- **settings.json Integration**: Auto-updates `hooks.before_run_command` config
43+
- **Safe by Design**: Scripts only match patterns — never execute commands themselves
44+
45+
## Example
46+
47+
```
48+
User: Help me set up command interception for our project
49+
50+
Agent: Which security scenario?
51+
→ Basic Security (rm -rf, git push --force, DROP TABLE, etc.)
52+
53+
Script type?
54+
→ Cross-platform (Shell + PowerShell)
55+
56+
[Generates .qoder/hooks/block-dangerous.sh + .ps1]
57+
[Updates .qoder/settings.json]
58+
59+
✅ Hooks generated! Try running a blocked command to verify.
60+
```
61+
62+
## Notes
63+
64+
- Pure knowledge skill — generates scripts and config, no external API calls
65+
- Hook scripts use `exit 0` (pass) or `exit 2` (block) — no other exit codes
66+
- Scripts read Qoder JSON input from stdin via `jq`
67+
- Read-only commands (`ls`, `cat`, `git status`) are never blocked
68+
- Existing settings.json entries are preserved — new hooks are appended

0 commit comments

Comments
 (0)