Typo3 simplify

From dirnbauer/webconsulting-skills · View interactive version

Typo3 simplify is an AI agent skill from the GitHub repository dirnbauer/webconsulting-skills. Simplify and refine TYPO3 extension code for clarity, consistency, and maintainability while preserving functionality. Reviews PHP classes, Fluid templates, TCA, Services.yaml, and ext_localconf/ext_tables for TYPO3 v14 best practices. Run after implementing a feature or before merging a PR. Use whe

How to use this skill

Skill file

TYPO3 Code Simplifier

Adapted from Boris Cherny's (Anthropic) code-simplifier agent for TYPO3 contexts.

Target: TYPO3 v14.x only.

Simplify and refine recently changed TYPO3 code. Preserve all functionality. Focus on

clarity over cleverness, TYPO3 API usage over custom implementations, and v14 patterns

over deprecated approaches.

Process

  1. Identify recently modified files (use git diff --name-only HEAD~1 or staged changes)
  2. Run three parallel review passes: Reuse, Quality, Efficiency
  3. Aggregate findings, deduplicate, sort by impact
  4. Apply fixes, verify no behavior change

Pass 1: TYPO3 API Reuse

Find custom implementations that duplicate what TYPO3 already provides.

Replace Custom Code with Core APIs

| Custom Pattern | TYPO3 API Replacement |

|---|---|

| Manual DB queries ($connection->executeQuery(...)) | QueryBuilder with named parameters |

| $GLOBALS['TYPO3_REQUEST'] | Inject ServerRequestInterface via middleware/controller |

| new FlashMessage(...) + manual queue | FlashMessageService via DI |

| Manual JSON response construction | JsonResponse from PSR-7 |

| GeneralUtility::makeInstance() | Constructor injection via Services.yaml |

| $GLOBALS['TSFE']->id | $request->getAttribute('frontend.page.information')?->getId() (canonical on v14; routing page id also works) |

| $GLOBALS['BE_USER'] | Inject Context or BackendUserAuthentication |

| ObjectManager::get() | Constructor DI |

| Manual file path resolution | PathUtility, Environment::getPublicPath() |

| Custom caching with globals | CacheManager via DI with cache configuration |

| BackendUtility::getRecord() for single field | QueryBuilder selecting only needed columns |

| Manual page tree traversal | RootlineUtility or PageRepository |

| GeneralUtility::_GP() / _POST() / _GET() | $request->getQueryParams() / getParsedBody() |

| $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'] writes | PSR-14 events or ExtensionConfiguration |

| Manual link generation | UriBuilder (backend) or ContentObjectRenderer::typoLink() |

Replace Deprecated Patterns (v14)

| Deprecated | v14 Replacement |

|---|---|

| ext_localconf.php hook arrays | #[AsEventListener] on PSR-14 events |

| $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] hooks | PSR-14 events |

| ext_tables.php module registration | Configuration/Backend/Modules.php |

| XCLASS | PSR-14 events or DI decoration |

| TCA eval for required, null | Dedicated TCA keys: required, nullable |

| TCA eval for trim | Still valid in v14 — no dedicated TCA replacement; keep trim in eval when you need it |

| renderType => 'inputDateTime' | 'type' => 'datetime' |

| 'type' => 'input', 'eval' => 'int' | 'type' => 'number' |

| items with numeric array keys | items with label/value keys |

Historical removals (pre–v14 code you may still read)

| Removed / legacy | When | Modern approach |

|---|---|---|

| switchableControllerActions | Deprecated in v10.3 (#89463), removed in v12.0 | Separate plugin registrations |

| Signal/Slot Dispatcher | Removed in v12 | PSR-14 events |

| AbstractPlugin (pi_base) | Made @internal v12.0 (#98281), deprecated v12.4 (#100639), removed v13.0 | Extbase or middleware |

Code quality (not deprecations)

| Topic | Guidance |

|---|---|

| $querySettings->setRespectStoragePage(false) | Valid Extbase API — prefer setting query settings in the repository factory or controller, not scattered in repositories, for clarity |

Pass 2: Code Quality

PHP Classes

// Before
class MyService
{
    private ConnectionPool $connectionPool;
    private Context $context;

    public function __construct(ConnectionPool $connectionPool, Context $context)
    {
        $this->connectionPool = $connectionPool;
        $this->context = $context;
    }

    public function getData($id)
    {
        // ...
    }
}

// After
final class MyService
{
    public function __construct(
        private readonly ConnectionPool $connectionPool,
        private readonly Context $context,
    ) {}

    public function getData(int $id): array
    {
        // ...
    }
}

Fluid Templates

TCA

Services.yaml

ext_localconf.php / ext_tables.php

Pass 3: Efficiency

Output Format

After analysis, report findings grouped by file:

## Classes/Controller/MyController.php

:42 — replace GeneralUtility::makeInstance(MyService::class) → constructor injection
:18 — add return type `: ResponseInterface`
:55 — deprecated: $GLOBALS['TSFE']->id → $request routing attribute
:67 — guard clause: invert condition, return early, reduce nesting

## Resources/Private/Templates/List.html

:12 — hardcoded string "No items found" → f:translate
:34 — manual <a href> → f:link.page

## Configuration/TCA/Overrides/tt_content.php

:8 — legacy items format `['Label', 'value']` → `['label' => 'Label', 'value' => 'value']`

Applied 7 fixes. No behavior changes. Run tests to verify.

Version fallbacks

When the same codebase must run on TYPO3 v13 and v14 (dual-version extensions), you may temporarily keep transitional patterns:

v14-Only Simplification Targets

The following simplification opportunities are v14-specific.

v14 Simplification Patterns **[v14 only]**

| Pattern | Simplification |

|---------|---------------|

| $GLOBALS['TSFE'] access | Fatal error in v14 (Breaking #107831) — replace with $request->getAttribute('frontend.page.information') |

| Extbase annotations (@validate) | Replace with #[\TYPO3\CMS\Extbase\Attribute\Validate] |

| MailMessage->send() | Inject TYPO3\CMS\Core\Mail\MailerInterface and call $this->mailer->send($email) |

| FlexFormService usage | Prefer FlexFormTools; FlexFormService remains as a BC alias in v14 but should not be used in new code |

| Bootstrap Modal JS | Frontend: native <dialog> where appropriate. Backend: use @typo3/backend/modal — it wraps native <dialog> in v14 (Breaking #107443); do not use raw Bootstrap modal JS |

| TCA ctrl.searchFields (removed in v14) | TYPO3 v14 derives backend search fields automatically; tune inclusion per column with 'searchable' => true/false (supported field types: input, text, email, link, slug, color, datetime (without custom dbType), flex, json, uuid) where supported |

| Custom localization parsers | Superseded by Symfony Translation Component integration (Feature #107436); BC maintained in v14 — prefer the new Symfony Translation API in new code |

| GeneralUtility::createVersionNumberedFilename() | Replace with SystemResourceFactory / SystemResourcePublisherInterface (System Resource API, Feature #107537) |


Credits & Attribution

This skill is based on the excellent work by

Anthropic.

Original repository: https://github.com/anthropics/claude-plugins-official/tree/main/plugins/code-simplifier

Special thanks to Anthropic for their generous open-source contributions, which helped shape this skill collection.

Adapted by webconsulting.at for this skill collection

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.