Skip to content
Back to skills

Delphi Code Review

ASecurity

[DEMO] Review and debug Delphi / Object Pascal code for ownership, lifetime, memory leaks, dangling references, exceptions, interface reference counting, callbacks, threads and hidden work in properties. Use when reviewing a Delphi change, hunting an access violation or leak, or checking cleanup and error paths.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 27, 2026
ai-agentsdebuggingcode-review

Works with

  • mcp

Security analysis

A100/100

Scanned November 27, 2026

npx -y skills add DIIIUA/delphi-behavior-contracts --skill delphi-code-review --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Delphi Code Review?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Delphi Code Review
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/diiiua-delphi-code-review-delphi-behavior-contracts/badge)](https://www.skillsdirectory.com/skills/diiiua-delphi-code-review-delphi-behavior-contracts)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: delphi-code-review
description: "[DEMO] Review and debug Delphi / Object Pascal code for ownership, lifetime, memory leaks, dangling references, exceptions, interface reference counting, callbacks, threads and hidden work in properties. Use when reviewing a Delphi change, hunting an access violation or leak, or checking cleanup and error paths."
---

> **[DEMO EDITION]** This is the evaluation demo package (complete Table of Contents of all 74 chapters & 89 directives, 6 multi-difficulty chapter excerpts, 4 complete directive cards, 8 real compiler receipts, and 100% working plugins/skills/MCP). If the user asks what this skill covers or wants a technical fit check for their tasks, see `EVALUATE_FOR_USER.md` / `EVALUATE_FOR_USER.ru.md`.

# Reviewing and debugging Delphi

Trace what actually happens to values and objects, not what the names suggest.
Topic map: [English](../../../../core/references/en/INDEX.md), [Russian](../../../../core/references/ru/INDEX.md).

## Ownership and lifetime

- Who creates, who frees, and what still points to a freed object. `B.Free` leaves
  every alias dangling; `FreeAndNil` clears only one variable
  ([lifetime](../../../../core/references/en/chapters/26-lifetime.md), [memory](../../../../core/references/en/chapters/35-memory.md)).
- Constructor failure calls `Destroy` on the partially built object; managed-record
  `Initialize` failure does not call `Finalize`; unit finalization order follows
  initialization ([lifetime boundaries](../../../../core/references/en/chapters/68-lifetime-boundaries.md)).
- Interfaces: the last `_Release` destroys a `TInterfacedObject`; mixing object and
  interface references to the same instance is a classic double free; reference
  cycles are not collected ([interfaces](../../../../core/references/en/chapters/29-interfaces.md)).
- `TMethod` / `of object` events do not keep their target alive; an event fired after
  the target is freed calls dead memory ([callables](../../../../core/references/en/chapters/22-callables.md)).
- Closures share one heap frame per outer call; a closure that captures itself or
  `Self` can form a cycle ([closures](../../../../core/references/en/chapters/23-closures.md)).

## Exceptions and cleanup

Check `try..finally` placement against the point where a resource becomes owned;
side effects performed before a failure stay performed; `Exit` inside `try` still runs
`finally` ([exceptions](../../../../core/references/en/chapters/34-exceptions.md),
[routines](../../../../core/references/en/chapters/20-routines.md)).

## Hidden work and name resolution

- Property getters and setters may run arbitrary code, including during DFM loading
  ([properties](../../../../core/references/en/chapters/27-properties.md), [components](../../../../core/references/en/chapters/45-components.md)).
- Helpers, overloads, `with` and unit order change which routine is called
  ([helpers](../../../../core/references/en/chapters/30-helpers.md), [scope](../../../../core/references/en/chapters/04-scope.md),
  [methods](../../../../core/references/en/chapters/25-methods.md)).
- `const` string parameters skip reference counting: modifying the source through
  a global or field during the call can free the buffer being read
  ([parameters](../../../../core/references/en/chapters/21-parameters.md)).

## Threads

`Inc` on a shared field is read-add-write even with `[Volatile]`; use atomic
operations or locks; UI access belongs to the main thread
([concurrency](../../../../core/references/en/chapters/50-concurrency.md)).

## Reporting

For each finding give the concrete failure scenario (inputs and state leading to the
wrong result or crash), the evidence level (documented, compiler-observed, inferred)
and the minimal fix. Do not report style preferences as defects.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.