Delphi

From G1Joshi/Agent-Skills · View interactive version

Delphi is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert Delphi / Object Pascal assistance covering VCL, FireMonkey, RTL, and enterprise desktop software. Use when maintaining or modernizing Windows desktop and cross-platform native applications.

How to use this skill

Skill file

Delphi / Object Pascal

Delphi (RAD Studio) and Free Pascal (Lazarus) keep Object Pascal alive. It is famous for Single EXE deployment and instant compilation.

When to Use

Quick Start

program HelloWorld;
{$APPTYPE CONSOLE}
uses
  System.SysUtils;

begin
  try
    Writeln('Hello from Delphi Object Pascal!');
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Core Concepts

Object Pascal Strong Typing & Class Architecture

Clean, readable object-oriented architecture with explicit interfaces:

unit OrderProcessor;

interface

type
  IOrderService = interface
    ['{8F3D1E1C-3A62-47CF-A98B-7D12A9E32049}']
    function ProcessOrder(const OrderId: Integer; const Amount: Double): Boolean;
  end;

  TOrderService = class(TInterfacedObject, IOrderService)
  public
    function ProcessOrder(const OrderId: Integer; const Amount: Double): Boolean;
  end;

implementation

function TOrderService.ProcessOrder(const OrderId: Integer; const Amount: Double): Boolean;
begin
  // Business logic execution
  Result := Amount > 0.0;
end;

end.

Visual Component Library (VCL) & FireMonkey (FMX)

FireDAC Unified Database Connectivity

High-performance data access layer:

var
  Query: TFDQuery;
begin
  Query := TFDQuery.Create(nil);
  try
    Query.Connection := FDConnection1;
    Query.SQL.Text := 'SELECT * FROM Customers WHERE Balance > :MinBalance';
    Query.ParamByName('MinBalance').AsCurrency := 1000.0;
    Query.Open;
    // Process records
  finally
    Query.Free;
  end;
end;

Common Patterns

Safe Memory Management with Try..Finally

Problem: Object memory leaks in non-ARC desktop platforms when exceptions occur.

Solution:

Use explicit try..finally destruction blocks:

procedure ProcessCustomerList;
var
  List: TStringList;
begin
  List := TStringList.Create;
  try
    List.Add('Customer 1');
    List.Add('Customer 2');
    List.SaveToFile('customers.txt');
  finally
    List.Free;
  end;
end;

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :---------------------------------------------------- | :-------------------------------------------------------------- | :------------------------------------------------------------------------------ |

| Access Violation at address ... (EAccessViolation) | Attempting to access an uninstantiated or freed object pointer. | Verify object was created with .Create before calling methods. |

| [dcc32 Fatal Error] F2084 Internal Error | Compiler cache corruption or circular unit dependency. | Clean build directory and resolve circular references in uses clauses. |

| Memory Leak Detected in ReportMemoryLeaksOnShutdown | Object created without matching .Free call. | Ensure every object creation is guarded with a try..finally Free; end; block. |

References

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.