create-psalm-config
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-psalm-config":https://skillpi.com/zh/skills/deepskill-3c89ed6b781f1f51f4210e4328a9658a40b6ded1e7a51e335e0de248e6661c78。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 项目生成 Psalm 配置。创建一个 psalm.xml 文件,包含适当的错误级别、插件设置、污点分析配置以及面向领域驱动设计(DDD)的特定设置,便于静态代码分析和类型检查。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: create-psalm-config
description: Generates Psalm configurations for PHP projects. Creates psalm.xml with appropriate error level, plugins, taint analysis, and DDD-specific settings.Psalm Configuration Generator
Generates optimized Psalm configurations for PHP 8.4+ projects.
Targets Psalm 6.x (vimeo/psalm: ^6.0) — errorLevel is an attribute of the root <psalm> element and only one <projectFiles> element is allowed.
Generated Files
psalm.xml # Main configuration
psalm-baseline.xml # Error baseline (if needed)
Configuration by Project Type
New Project (Level 1-2)
<?xml version="1.0"?>
<psalm
errorLevel="2"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="true"
findUnusedVariablesAndParams="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm>
Existing Project with Baseline
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<directory name="src/Legacy"/>
</ignoreFiles>
</projectFiles>
<issueHandlers>
<!-- Gradually enable -->
<MixedAssignment errorLevel="suppress"/>
<MixedMethodCall errorLevel="suppress"/>
<MixedArgument errorLevel="suppress"/>
</issueHandlers>
</psalm>
DDD Project Configuration
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="true"
findUnusedVariablesAndParams="true"
strictBinaryOperands="true"
phpVersion="8.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<directory name="src/Infrastructure/Migrations"/>
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
<pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin"/>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
</plugins>
<issueHandlers>
<!-- Domain layer - strictest -->
<MixedAssignment>
<errorLevel type="error">
<directory name="src/Domain"/>
</errorLevel>
</MixedAssignment>
<!-- Doctrine entities -->
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<directory name="src/Infrastructure/Doctrine/Entity"/>
</errorLevel>
</PropertyNotSetInConstructor>
<!-- Value Objects immutability -->
<ImmutablePropertyAssignment>
<errorLevel type="error">
<directory name="src/Domain"/>
</errorLevel>
</ImmutablePropertyAssignment>
<!-- Allow missing return types in interfaces (for contravariance) -->
<MissingReturnType>
<errorLevel type="suppress">
<directory name="src/Domain/Repository"/>
</errorLevel>
</MissingReturnType>
</issueHandlers>
<!-- Stubs for external libraries -->
<stubs>
<file name="stubs/Doctrine.phpstub"/>
</stubs>
</psalm>
Plugin Configuration
PHPUnit Plugin
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
Doctrine Plugin
<plugins>
<pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin">
<enableObjectManagerGenerator value="true"/>
</pluginClass>
</plugins>
Symfony Plugin
<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin">
<containerXml>var/cache/dev/App_KernelDevDebugContainer.xml</containerXml>
</pluginClass>
</plugins>
Laravel Plugin
<plugins>
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
</plugins>
Issue Handlers
Common Suppressions
<issueHandlers>
<!-- Allow mixed in legacy code -->
<MixedAssignment>
<errorLevel type="suppress">
<directory name="src/Legacy"/>
</errorLevel>
</MixedAssignment>
<!-- Allow property initialization in setUp() -->
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</PropertyNotSetInConstructor>
<!-- Suppress for mocks -->
<UndefinedMagicMethod>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</UndefinedMagicMethod>
<!-- Allow unused parameters in event handlers -->
<UnusedParam>
<errorLevel type="suppress">
<file name="src/Application/EventHandler/*.php"/>
</errorLevel>
</UnusedParam>
<!-- Suppress deprecated in migrations -->
<DeprecatedMethod>
<errorLevel type="suppress">
<directory name="src/Infrastructure/Migrations"/>
</errorLevel>
</DeprecatedMethod>
</issueHandlers>
Strict Mode for Domain
<issueHandlers>
<!-- Enforce strict types in Domain -->
<MixedAssignment>
<errorLevel type="error">
<directory name="src/Domain"/>
</errorLevel>
<errorLevel type="suppress">
<directory name="src/Infrastructure"/>
</errorLevel>
</MixedAssignment>
<!-- Enforce immutability -->
<ImmutablePropertyAssignment>
<errorLevel type="error">
<directory name="src/Domain/ValueObject"/>
</errorLevel>
</ImmutablePropertyAssignment>
</issueHandlers>
Taint Analysis Configuration
Taint analysis is enabled by the --taint-analysis CLI flag, not by a config attribute.
Superglobals ($_GET, $_POST, ...) are built-in sources; custom sources are marked in code
with @psalm-taint-source input. Only the sink severities are configurable in psalm.xml:
<?xml version="1.0"?>
<psalm
errorLevel="2"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<!-- Taint sinks -->
<issueHandlers>
<TaintedSql errorLevel="error"/>
<TaintedHtml errorLevel="error"/>
<TaintedShell errorLevel="error"/>
<TaintedFile errorLevel="error"/>
<TaintedHeader errorLevel="error"/>
<TaintedSSRF errorLevel="error"/>
</issueHandlers>
</psalm>
Baseline Management
Generate Baseline
# Generate baseline for all errors
vendor/bin/psalm --set-baseline=psalm-baseline.xml
# Update baseline (remove fixed issues)
vendor/bin/psalm --update-baseline
# Analyze with baseline
vendor/bin/psalm
Baseline Format
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.x">
<file src="src/SomeClass.php">
<MixedAssignment>
<code>$variable</code>
</MixedAssignment>
</file>
</files>
Level Migration Guide
Error Levels
| Level | Description | Use Case |
|---|---|---|
| 1 | Strictest | New projects, Domain layer |
| 2 | Very strict | Clean codebases |
| 3 | Strict | Recommended default |
| 4 | Relaxed | Mixed codebases |
| 5-7 | Permissive | Legacy code |
| 8 | Very permissive | Initial analysis only |
Migration Steps
<!-- Step 1: Start with baseline -->
<psalm errorLevel="8" errorBaseline="psalm-baseline.xml">
<!-- Step 2: Decrease level, update baseline -->
<psalm errorLevel="7" errorBaseline="psalm-baseline.xml">
<!-- Step 3: Continue until target level -->
<psalm errorLevel="3">
CI Configuration
GitHub Actions
psalm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- run: composer install
- run: vendor/bin/psalm --output-format=github
GitLab CI
psalm:
script:
- vendor/bin/psalm --output-format=checkstyle > psalm-report.xml
artifacts:
paths:
- psalm-report.xml
Security Scan
psalm-taint:
script:
- vendor/bin/psalm --taint-analysis
allow_failure: true
Generation Instructions
-
Analyze project:
- Check
composer.jsonfor Psalm version - Check existing
psalm.xml - Identify framework
- Count existing errors
- Check
-
Determine level:
- New project: Level 1-2
- Existing clean: Level 3
- Legacy: Level 5+ with baseline
-
Add plugins:
- PHPUnit always
- Doctrine if ORM
- Symfony/Laravel if framework
-
Configure issue handlers:
- Strict for Domain
- Relaxed for Infrastructure/Legacy
Usage
Provide:
- Project type (new/existing/legacy)
- Framework (Symfony, Laravel, none)
- Target level (optional)
- Taint analysis (yes/no)
The generator will:
- Create appropriate configuration
- Add relevant plugins
- Configure issue handlers
- Set up baseline if needed
- Include taint analysis if requested
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Psalm 配置文件生成功能,针对 PHP 项目开发者具有明确的技术实用价值
- 覆盖新/现有/DDD 项目等多种场景,适用性广泛
亮点
- description 明确说明功能为生成 Psalm 配置,包含错误级别、插件、污点分析等关键要素
- 触发词精准完整,覆盖多种项目类型和框架
亮点
- 文档结构清晰,包含多个配置示例和完整章节
- frontmatter 完整,有端到端示例,单文件长度合理
亮点
- 提供了完整的 XML 配置示例,参数正确
- 覆盖了主要使用场景,包含 CI/CD 集成说明
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- getpsalm.org
- www.w3.org
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。