重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
code-style-validator by oimiragieo/agent-studio
npx skills add https://github.com/oimiragieo/agent-studio --skill code-style-validator无需单独下载:该技能运行仓库内工具 .claude/tools/cli/security-lint.cjs。
winget install OpenJS.NodeJS.LTS (Windows)、brew install node (macOS)。基于 AST 的验证: 使用带有选择器/模式的 ESLint(或等效工具);规则监听特定的节点类型。在编写自定义规则之前,优先使用现有的社区规则;自定义规则需要 meta(类型、可修复性、模式)和 create。
流程: 检查命名(camelCase/PascalCase/snake_case)、缩进、导入顺序、函数/类结构、注释风格。在预提交和 CI 中运行;尽可能提供自动修复。
技巧: 使用 --fix 处理可自动修复的规则;与 security-lint 结合用于策略。为文档和工具清晰地定义规则元数据。使用 AST 选择器进行精确的模式匹配(节点类型、属性、子节点/兄弟节点)。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
建议的钩子: 预提交:运行 security-lint(技能脚本)或 ESLint;失败时阻止提交。与 developer(次要)、code-reviewer(次要)、qa(CI)一起使用。
工作流: 与 code-reviewer(次要)、developer(次要)一起使用。流程:提交前或在 CI 中 → 运行验证器 → 修复或阻止。参见 code-review-workflow.md、validation 钩子。
分析代码库以识别风格模式:
使用特定语言的 AST 解析器:
TypeScript/JavaScript : </execution_process>
const ts = require('typescript');
const fs = require('fs');
function validateTypeScriptFile(filePath) {
const sourceCode = fs.readFileSync(filePath, 'utf8');
const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.Latest, true);
const issues = [];
// Validate naming conventions
ts.forEachChild(sourceFile, node => {
if (ts.isFunctionDeclaration(node) && node.name) {
if (!/^[a-z][a-zA-Z0-9]*$/.test(node.name.text)) {
issues.push({
line: sourceFile.getLineAndCharacterOfPosition(node.name.getStart()).line + 1,
message: `Function name "${node.name.text}" should be camelCase`,
});
}
}
});
return issues;
}
</code_example>
<code_example> Python AST 验证 :
import ast
import re
def validate_python_file(file_path):
with open(file_path, 'r') as f:
source_code = f.read()
tree = ast.parse(source_code)
issues = []
for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef):
if not re.match(r'^[a-z][a-z0-9_]*$', node.name):
issues.append({
'line': node.lineno,
'message': f'Function name "{node.name}" should be snake_case'
})
return issues
</code_example>
<code_example> 风格检查 :
命名约定 :
格式化 :
结构 :
<code_example> 使用示例 (模板 - 请先实现验证器):
验证单个文件 :
# After implementing your validator:
node validate-code-style.js src/components/Button.tsx
验证目录 :
# After implementing your validator:
node validate-code-style.js src/components/
输出格式 :
{
"file": "src/components/Button.tsx",
"valid": false,
"issues": [
{
"line": 15,
"column": 10,
"rule": "naming-convention",
"message": "Variable 'UserData' should be camelCase: 'userData'",
"severity": "error"
},
{
"line": 23,
"column": 5,
"rule": "indentation",
"message": "Expected 2 spaces, found 4",
"severity": "warning"
}
],
"summary": {
"total": 2,
"errors": 1,
"warnings": 1
}
}
</code_example>
<code_example> 预提交钩子 (模板 - 请先实现验证器):
#!/bin/bash
# .git/hooks/pre-commit
changed_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx|js|jsx|py)$')
for file in $changed_files; do
# Replace with your actual validator path
if ! node validate-code-style.js "$file"; then
echo "Code style validation failed for $file"
exit 1
fi
done
</code_example>
<code_example> CI/CD 集成 (模板 - 请先实现验证器):
# .github/workflows/code-style.yml
- name: Validate code style
run: |
# Replace with your actual validator path
node validate-code-style.js src/
if [ $? -ne 0 ]; then
echo "Code style validation failed"
exit 1
fi
</code_example>
| 反面模式 | 失败原因 | 正确方法 |
|---|---|---|
| 基于正则表达式的风格检查 | 在多行、字符串和注释上失效 | 使用基于 AST 的工具(ESLint、Prettier) |
| 为已覆盖的标准编写自定义规则 | 维护成本高;与社区不一致 | 首先配置现有的 ESLint/Prettier 规则 |
| 在 CI 中因警告而阻塞 | 过度摩擦导致团队禁用风格检查 | 仅因错误而阻塞;记录警告 |
| 没有自动修复的风格验证 | 手动修复解决率低 | 始终在发现问题的同时提供自动修复命令 |
| 仅在本地运行,不在 CI 中运行 | 开发者经常绕过预提交钩子 | 在预提交和 CI 流水线中都运行 |
开始前: 阅读 .claude/context/memory/learnings.md
完成后:
.claude/context/memory/learnings.md.claude/context/memory/issues.md.claude/context/memory/decisions.md假设中断:如果不在记忆中,则视为未发生。
每周安装次数
65
仓库
GitHub 星标数
19
首次出现时间
Jan 27, 2026
安全审计
安装于
github-copilot63
gemini-cli62
codex61
kimi-cli61
amp61
cursor61
No separate download: the skill runs the in-repo tool .claude/tools/cli/security-lint.cjs.
winget install OpenJS.NodeJS.LTS (Windows), brew install node (macOS).AST-based validation: Use ESLint (or equivalent) with selectors/patterns; rules listen for specific node types. Prefer existing community rules before writing custom ones; custom rules need meta (type, fixable, schema) and create.
Process: Check naming (camelCase/PascalCase/snake_case), indentation, import order, function/class structure, comment style. Run in pre-commit and CI; provide auto-fix where possible.
Hacks: Use --fix for auto-fixable rules; combine with security-lint for policy. Define rule metadata clearly for docs and tooling. Use AST selectors for precise pattern matching (node type, attributes, child/sibling).
ESLint: Use in project, custom rules, selectors. No cert; skill data: AST-based validation, pre-commit/CI, auto-fix, naming/indent/imports.
Suggested hooks: Pre-commit: run security-lint (skill script) or ESLint; block commit on failure. Use with developer (secondary), code-reviewer (secondary), qa (CI).
Workflows: Use with code-reviewer (secondary), developer (secondary). Flow: before commit or in CI → run validator → fix or block. See code-review-workflow.md, validation hooks.
Analyze the codebase to identify style patterns:
Use language-specific AST parsers:
TypeScript/JavaScript : </execution_process>
const ts = require('typescript');
const fs = require('fs');
function validateTypeScriptFile(filePath) {
const sourceCode = fs.readFileSync(filePath, 'utf8');
const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.Latest, true);
const issues = [];
// Validate naming conventions
ts.forEachChild(sourceFile, node => {
if (ts.isFunctionDeclaration(node) && node.name) {
if (!/^[a-z][a-zA-Z0-9]*$/.test(node.name.text)) {
issues.push({
line: sourceFile.getLineAndCharacterOfPosition(node.name.getStart()).line + 1,
message: `Function name "${node.name.text}" should be camelCase`,
});
}
}
});
return issues;
}
</code_example>
<code_example> Python AST Validation :
import ast
import re
def validate_python_file(file_path):
with open(file_path, 'r') as f:
source_code = f.read()
tree = ast.parse(source_code)
issues = []
for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef):
if not re.match(r'^[a-z][a-z0-9_]*$', node.name):
issues.append({
'line': node.lineno,
'message': f'Function name "{node.name}" should be snake_case'
})
return issues
</code_example>
<code_example> Style Checks :
Naming Conventions :
Formatting :
Structure :
<code_example> Usage Examples (Template - implement validator first):
Validate Single File :
# After implementing your validator:
node validate-code-style.js src/components/Button.tsx
Validate Directory :
# After implementing your validator:
node validate-code-style.js src/components/
Output Format :
{
"file": "src/components/Button.tsx",
"valid": false,
"issues": [
{
"line": 15,
"column": 10,
"rule": "naming-convention",
"message": "Variable 'UserData' should be camelCase: 'userData'",
"severity": "error"
},
{
"line": 23,
"column": 5,
"rule": "indentation",
"message": "Expected 2 spaces, found 4",
"severity": "warning"
}
],
"summary": {
"total": 2,
"errors": 1,
"warnings": 1
}
}
</code_example>
<code_example> Pre-commit Hook (Template - implement validator first):
#!/bin/bash
# .git/hooks/pre-commit
changed_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx|js|jsx|py)$')
for file in $changed_files; do
# Replace with your actual validator path
if ! node validate-code-style.js "$file"; then
echo "Code style validation failed for $file"
exit 1
fi
done
</code_example>
<code_example> CI/CD Integration (Template - implement validator first):
# .github/workflows/code-style.yml
- name: Validate code style
run: |
# Replace with your actual validator path
node validate-code-style.js src/
if [ $? -ne 0 ]; then
echo "Code style validation failed"
exit 1
fi
</code_example>
| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
| Regex-based style checking | Breaks on multi-line, strings, and comments | Use AST-based tools (ESLint, Prettier) |
| Custom rules for covered standards | High maintenance; inconsistent with community | Configure existing ESLint/Prettier rules first |
| Blocking CI on warnings | Excessive friction causes teams to disable style checks | Block only on errors; log warnings |
| Style validation without auto-fix | Manual fixes have low resolution rate | Always provide auto-fix commands alongside findings |
| Running only locally, not in CI | Developers bypass pre-commit hooks regularly | Run in both pre-commit and CI pipeline |
Before starting: Read .claude/context/memory/learnings.md
After completing:
.claude/context/memory/learnings.md.claude/context/memory/issues.md.claude/context/memory/decisions.mdASSUME INTERRUPTION: If it's not in memory, it didn't happen.
Weekly Installs
65
Repository
GitHub Stars
19
First Seen
Jan 27, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot63
gemini-cli62
codex61
kimi-cli61
amp61
cursor61
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
48,700 周安装
通用项目发布工具 - 多语言更新日志自动生成 | 支持Node.js/Python/Rust/Claude插件
62 周安装
Edge Pipeline Orchestrator:自动化金融交易策略流水线编排工具
62 周安装
Python ROI 计算器:投资回报率、营销ROI、盈亏平衡分析工具
62 周安装
Salesforce Hyperforce 2025架构指南:云原生、零信任安全与开发最佳实践
62 周安装
PowerShell 2025 重大变更与迁移指南:版本移除、模块停用、WMIC替代方案
62 周安装
2025安全优先Bash脚本编写指南:输入验证、命令注入与路径遍历防护
62 周安装