Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/secondlifes/delphi-expert/refactoringgit clone --depth 1 https://github.com/SecondLifes/delphi-expertWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/secondlifes/delphi-expert/refactoring)<a href="https://agentmods.dev/rules/secondlifes/delphi-expert/refactoring"><img src="https://agentmods.dev/badge/rules/secondlifes/delphi-expert/refactoring.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.02818 |
| Opus 5 | $0.00000 | $0.01409 |
| Sonnet 5 | $0.00000 | $0.00564 |
| Haiku 4.5 | $0.00000 | $0.00282 |
Grade A, and why
refactoring scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 406 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Delphi Code Refactoring — Rules
Use these rules when detecting or fixing code smells in Object Pascal. Refactoring doesn't change behavior — it just improves the internal structure.
🔴 Code Smells that Require Immediate Refactoring
| Code Smell | Symptom | Technique |
|---|---|---|
| Long method | > 20 lines | Extract Method |
| Bloated class | > 300 lines / multiple responsibilities | Extract Class |
| Magic numbers | if Age > 18 |
Replace with Constant |
| Deep Nesting | if...if...if above 2 levels |
Replace with Guard Clauses |
| Duplicate code | Same block in ≥ 2 places | Extract Method / Pull Up |
| Excessive parameters | Method with > 3 parameters | Introduce Parameter Object |
| Mixed UI logic | Business in OnClick |
Move Method to Service |
with statement |
with DataSet do... |
Remove With |
| Unnecessary temporary variable | Used only once | Inline Temp |
| Conditional with type | if Obj is TSubClass then |
Replace Conditional with Polymorphism |
| Message chain | A.B.C.D.Execute |
Law of Demeter / Introduce Method |
| Comment explaining what | The code should explain itself | Rename + Extract Method |
✂️ Extract Method
Extract purposeful blocks of code into named methods.
//❌ BEFORE — long method without separation of responsibilities
procedure TOrderService.PlaceOrder(AOrder: TOrder);
var
LTotal: Currency;
LDiscount: Currency;
LItem: TOrderItem;
begin
// Calcula total
LTotal := 0;
for LItem in AOrder.Items do
LTotal := LTotal + (LItem.UnitPrice * LItem.Quantity);
//Apply discount
if AOrder.Customer.IsVip then
LDiscount := LTotal * 0.10
else if LTotal > 500 then
LDiscount := LTotal * 0.05
else
LDiscount := 0;
LTotal := LTotal - LDiscount;
//Validates stock
for LItem in AOrder.Items do
begin
if LItem.Quantity > LItem.Product.StockQty then
raise EInvalidOrderException.CreateFmt(
'Estoque insuficiente: %s', [LItem.Product.Name]);
end;
AOrder.TotalAmount := LTotal;
FRepository.Save(AOrder);
end;
//✅ AFTER — each responsibility in its own method
procedure TOrderService.PlaceOrder(AOrder: TOrder);
begin
ValidateStock(AOrder);
AOrder.TotalAmount := CalculateTotalWithDiscount(AOrder);
FRepository.Save(AOrder);
end;
function TOrderService.CalculateSubtotal(AOrder: TOrder): Currency;
var LItem: TOrderItem;
begin
Result := 0;
for LItem in AOrder.Items do
Result := Result + (LItem.UnitPrice * LItem.Quantity);
end;
function TOrderService.CalculateDiscount(AOrder: TOrder; ASubtotal: Currency): Currency;
const
VIP_DISCOUNT_RATE = 0.10;
BULK_DISCOUNT_RATE = 0.05;
BULK_DISCOUNT_MINIMUM = 500;
begin
if AOrder.Customer.IsVip then
Result := ASubtotal * VIP_DISCOUNT_RATE
else if ASubtotal > BULK_DISCOUNT_MINIMUM then
Result := ASubtotal * BULK_DISCOUNT_RATE
else
Result := 0;
end;
function TOrderService.CalculateTotalWithDiscount(AOrder: TOrder): Currency;
var LSubtotal: Currency;
begin
LSubtotal := CalculateSubtotal(AOrder);
Result := LSubtotal - CalculateDiscount(AOrder, LSubtotal);
end;
procedure TOrderService.ValidateStock(AOrder: TOrder);
var LItem: TOrderItem;
begin
for LItem in AOrder.Items do
if LItem.Quantity > LItem.Product.StockQty then
raise EInvalidOrderException.CreateFmt(
'Estoque insuficiente: %s', [LItem.Product.Name]);
end;
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- today First seen · 406 lines · 0 tokens per session scan A ebee58831726
refactoring is a cursor rule published in the GitHub repository SecondLifes/delphi-expert (3 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,818 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.