check-code-style
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "check-code-style":https://skillpi.com/zh/skills/deepskill-5abf4aabadc764223128ba1e59497015e4cf1dd7fe58bc4d0fee4e0470b4795b。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
分析 PHP 代码的风格问题。检查是否符合 PSR-12 规范、格式一致性、空格使用以及行长度。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 减记
- 实测状态
- 未测试
文件浏览
Frontmatter
name: check-code-style
description: Analyzes PHP code for style issues. Checks PSR-12 compliance, formatting consistency, whitespace usage, line length.Code Style Check
Analyze PHP code for style consistency and PSR-12 compliance.
Detection Patterns
1. PSR-12 Violations
// BAD: Opening brace on same line for class
class User {
}
// GOOD: Opening brace on new line
class User
{
}
// BAD: Opening brace on new line for methods
public function getName()
{
}
// GOOD: Opening brace on same line for control structures
if ($condition) {
}
// BAD: No space after keywords
if($condition) {}
foreach($items as $item) {}
// GOOD: Space after keywords
if ($condition) {}
foreach ($items as $item) {}
2. Line Length
// BAD: Exceeds 120 characters
$result = $this->veryLongServiceName->processWithManyParameters($parameter1, $parameter2, $parameter3, $parameter4, $parameter5);
// GOOD: Broken into multiple lines
$result = $this->veryLongServiceName->processWithManyParameters(
$parameter1,
$parameter2,
$parameter3,
$parameter4,
$parameter5
);
3. Indentation
// BAD: Mixed tabs and spaces
class User
{
private string $name; // Tab
private int $age; // Spaces
}
// GOOD: Consistent 4 spaces
class User
{
private string $name;
private int $age;
}
4. Blank Lines
// BAD: No blank line after namespace
namespace App\Service;
use App\Repository;
// GOOD: Blank line after namespace
namespace App\Service;
use App\Repository;
// BAD: No blank line between methods
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
// GOOD: Blank line between methods
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
5. Trailing Whitespace
// BAD: Trailing spaces at end of line
$name = 'John';
$age = 25;
// GOOD: No trailing whitespace
$name = 'John';
$age = 25;
6. Use Statement Ordering
// BAD: Unordered use statements
use App\Service\OrderService;
use App\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use App\Repository\UserRepository;
// GOOD: Grouped and alphabetized
use App\Entity\User;
use App\Repository\UserRepository;
use App\Service\OrderService;
use Symfony\Component\HttpFoundation\Request;
7. Array Syntax
// BAD: Long array syntax
$items = array(1, 2, 3);
$config = array(
'key' => 'value',
);
// GOOD: Short array syntax
$items = [1, 2, 3];
$config = [
'key' => 'value',
];
8. Operator Spacing
// BAD: Inconsistent spacing
$sum=$a+$b;
$name = $first.$last;
$condition = $a>$b;
// GOOD: Consistent spacing
$sum = $a + $b;
$name = $first . $last;
$condition = $a > $b;
9. Comma Spacing
// BAD: No space after comma
$result = calculate($a,$b,$c);
$array = [1,2,3];
// GOOD: Space after comma
$result = calculate($a, $b, $c);
$array = [1, 2, 3];
10. Return Type Declaration
// BAD: Space before colon
public function getName() : string {}
// GOOD: No space before colon
public function getName(): string {}
// BAD: No space after colon
public function getName():string {}
// GOOD: Space after colon
public function getName(): string {}
Grep Patterns
# Opening brace on same line for class
Grep: "class\s+\w+\s*\{" --glob "**/*.php"
# No space after if/foreach/while
Grep: "(if|foreach|while|for|switch)\(" --glob "**/*.php"
# Lines over 120 chars (needs manual check)
Grep: "^.{121,}$" --glob "**/*.php"
# array() instead of []
Grep: "array\s*\(" --glob "**/*.php"
# Missing space around operators
Grep: "[^ ]==[^ ]|[^ ]!=[^ ]" --glob "**/*.php"
Severity Classification
| Pattern | Severity |
|---|---|
| Mixed tabs/spaces | 🟠 Major |
| PSR-12 brace placement | 🟡 Minor |
| Line length > 120 | 🟡 Minor |
| Operator spacing | 🟢 Suggestion |
| Use statement order | 🟢 Suggestion |
Automated Fixing
Most style issues can be automatically fixed:
# PHP-CS-Fixer
php-cs-fixer fix --rules=@PSR12
# PHP_CodeSniffer
phpcbf --standard=PSR12 src/
Output Format
### Style Issue: [Description]
**Severity:** 🟠/🟡/🟢
**Location:** `file.php:line`
**Rule:** PSR-12 / Project Standard
**Issue:**
[Description of the style violation]
**Current:**
```php
if($condition){
Suggested:
if ($condition) {
Auto-fix:
Run php-cs-fixer fix --rules=@PSR12
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 PHP 代码风格分析功能,针对 PSR-12 规范、格式一致性等常见问题
- 具有明确的开发者工具定位,实用价值明确
亮点
- description 字段完整描述了功能,触发词清晰
亮点
- 结构完整,包含清晰的 Detection Patterns 分类和 BAD/GOOD 示例对比
- 提供了 Grep Patterns、Severity Classification 和 Automated Fixing 方案
待提升项
-
缺少异常处理说明 原报告严重程度:轻微
未提及如何处理 Grep 命令执行失败、文件权限问题、PHP 环境未安装等异常情况
改进建议:建议在文档中补充常见异常的处理建议或错误提示
亮点
- 提供了具体的 Grep 命令和自动化修复工具推荐,工具来源明确
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。