UFO-Tech code style

The UFO-Tech team's optional PHP code style — strict typing, DTOs, thin controllers, services, early returns. For projects that adopt it.

Install through your agent — tell it:

Read https://ufo-tech.space/ai/install.md and install the ufo-code-style rule from the UFO Tech catalog into this project.

Installation

Claude Code

Into the project — docs/ai/ufo-code-style.md

macOS, Linux, WSL, Git Bash

mkdir -p "docs/ai"
curl -fsSL https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -o "docs/ai/ufo-code-style.md"

Windows PowerShell

New-Item -ItemType Directory -Force "docs\ai" | Out-Null
Invoke-WebRequest https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -OutFile "docs\ai\ufo-code-style.md"

Add this line to CLAUDE.md in the project root:

@docs/ai/ufo-code-style.md

Codex

Into the project — docs/ai/ufo-code-style.md

macOS, Linux, WSL, Git Bash

mkdir -p "docs/ai"
curl -fsSL https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -o "docs/ai/ufo-code-style.md"

Windows PowerShell

New-Item -ItemType Directory -Force "docs\ai" | Out-Null
Invoke-WebRequest https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -OutFile "docs\ai\ufo-code-style.md"

Add this line to AGENTS.md in the project root:

Follow docs/ai/ufo-code-style.md.

Cursor

Into the project — .cursor/rules/ufo-code-style.mdc

macOS, Linux, WSL, Git Bash

mkdir -p ".cursor/rules"
curl -fsSL https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -o ".cursor/rules/ufo-code-style.mdc"

Windows PowerShell

New-Item -ItemType Directory -Force ".cursor\rules" | Out-Null
Invoke-WebRequest https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -OutFile ".cursor\rules\ufo-code-style.mdc"

Prepend Cursor frontmatter: description (one line), globs (if the rule targets specific paths), alwaysApply: false.

GitHub Copilot

Into the project — .github/instructions/ufo-code-style.instructions.md

macOS, Linux, WSL, Git Bash

mkdir -p ".github/instructions"
curl -fsSL https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -o ".github/instructions/ufo-code-style.instructions.md"

Windows PowerShell

New-Item -ItemType Directory -Force ".github\instructions" | Out-Null
Invoke-WebRequest https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -OutFile ".github\instructions\ufo-code-style.instructions.md"

Prepend frontmatter with applyTo, e.g. applyTo: "src/**".

AGENTS.md

Into the project — docs/ai/ufo-code-style.md

macOS, Linux, WSL, Git Bash

mkdir -p "docs/ai"
curl -fsSL https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -o "docs/ai/ufo-code-style.md"

Windows PowerShell

New-Item -ItemType Directory -Force "docs\ai" | Out-Null
Invoke-WebRequest https://ufo-tech.space/ai/files/rule/ufo-code-style/universal/ufo-code-style.md -OutFile "docs\ai\ufo-code-style.md"

Add this line to AGENTS.md in the project root:

Follow docs/ai/ufo-code-style.md.

About

The UFO-Tech team's optional code style for PHP projects. Add it only to projects that adopt this style; if a project already has its own conventions, the agent must follow those.

What's inside

  • declare(strict_types=1);, full typing of arguments, return values and properties;
  • DTOs and value objects instead of associative arrays, immutable by default;
  • thin controllers, business logic in services, repositories only for data access;
  • early returns, shallow nesting and short methods.

The file is in English.

<div class="docs-page-votes" data-page-votes hidden data-endpoint="/votes" role="group" aria-label="Rate this page"> <button class="docs-page-votes__button" type="button" data-vote="1" aria-pressed="false" title="Helpful"> <span aria-hidden="true">👍</span> <span class="visually-hidden">Helpful</span> <span data-vote-count>0</span> </button> <button class="docs-page-votes__button" type="button" data-vote="-1" aria-pressed="false" title="Not helpful"> <span aria-hidden="true">👎</span> <span class="visually-hidden">Not helpful</span> <span data-vote-count>0</span> </button> </div> <p class="docs-page-counters" data-page-counters hidden data-endpoint="/_e/page" data-label-total="Viewed {count} {times}" data-label-now="Viewing now: {count}" data-times="{&quot;one&quot;:&quot;time&quot;,&quot;few&quot;:&quot;times&quot;,&quot;many&quot;:&quot;times&quot;,&quot;other&quot;:&quot;times&quot;}"> <span data-page-counters-total></span> <span aria-hidden="true">·</span> <span data-page-counters-now></span> </p>