create-psalm-config

Generate a Psalm configuration for a PHP project. Create a psalm.xml file that specifies appropriate error levels, plugin settings, taint analysis configuration, and DDD-specific options to support static analysis and type checking.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-psalm-config" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-3c89ed6b781f1f51f4210e4328a9658a40b6ded1e7a51e335e0de248e6661c78. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Generate a Psalm configuration for a PHP project. Create a psalm.xml file that specifies appropriate error levels, plugin settings, taint analysis configuration, and DDD-specific options to support static analysis and type checking.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Psalm configurations for PHP projects. Creates psalm.xml with appropriate error level, plugins, taint analysis, and DDD-specific settings.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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

  1. Analyze project:

    • Check composer.json for Psalm version
    • Check existing psalm.xml
    • Identify framework
    • Count existing errors
  2. Determine level:

    • New project: Level 1-2
    • Existing clean: Level 3
    • Legacy: Level 5+ with baseline
  3. Add plugins:

    • PHPUnit always
    • Doctrine if ORM
    • Symfony/Laravel if framework
  4. 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:

  1. Create appropriate configuration
  2. Add relevant plugins
  3. Configure issue handlers
  4. Set up baseline if needed
  5. Include taint analysis if requested

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供 Psalm 配置文件生成功能,针对 PHP 项目开发者具有明确的技术实用价值
  • 覆盖新/现有/DDD 项目等多种场景,适用性广泛
Trigger Precision90/100

Highlights

  • description 明确说明功能为生成 Psalm 配置,包含错误级别、插件、污点分析等关键要素
  • 触发词精准完整,覆盖多种项目类型和框架
Structure and Standards90/100

Highlights

  • 文档结构清晰,包含多个配置示例和完整章节
  • frontmatter 完整,有端到端示例,单文件长度合理
Execution Reliability85/100

Highlights

  • 提供了完整的 XML 配置示例,参数正确
  • 覆盖了主要使用场景,包含 CI/CD 集成说明
Evidence Verifiability (mean of the first four)85/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • getpsalm.org
  • www.w3.org

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.