|
| 1 | +--- |
| 2 | +name: encodingfix-delphi-cleanup |
| 3 | +description: Use EncodingFixTool whenever an AI agent edits, generates, patches, or reviews Delphi/Pascal files and needs safe CRLF or UTF-8 cleanup. Trigger this skill after apply_patch, WSL/Linux tools, formatters, bulk rewrites, or pre-commit cleanup involving .pas, .dpr, .dpk, .inc, .dfm, or .dproj files, even when the user only mentions wrong line endings or encoding drift. |
| 4 | +--- |
| 5 | + |
| 6 | +# EncodingFix Delphi Cleanup |
| 7 | + |
| 8 | +Run EncodingFixTool after AI/editor work may have changed Delphi line endings or encoding. Keep the cleanup narrow, auditable, and separate from build/test validation. |
| 9 | + |
| 10 | +## Use This For |
| 11 | + |
| 12 | +- Delphi files: `.pas`, `.dpr`, `.dpk`, `.inc`, `.dfm`, `.dproj`. |
| 13 | +- AI-generated or patched Delphi code that should use Windows CRLF. |
| 14 | +- Delphi files that should be UTF-8 with BOM when non-ASCII text is present. |
| 15 | +- Pre-build or pre-commit cleanup after code generation, patching, formatters, WSL, or Linux tooling. |
| 16 | + |
| 17 | +Do not use it for unrelated dirty files, vendored code, non-Delphi cleanup, or as a replacement for the repo's build/test gates. Binary `.dfm` files are safe because EncodingFixTool skips them. |
| 18 | + |
| 19 | +## Core Workflow |
| 20 | + |
| 21 | +1. Check the dirty set first: |
| 22 | + |
| 23 | +```powershell |
| 24 | +git status --short |
| 25 | +``` |
| 26 | + |
| 27 | +If unrelated user changes are dirty, avoid broad cleanup. Narrow `path=...`, override `ext=...`, or ask before touching files outside our work. |
| 28 | + |
| 29 | +2. In a Git worktree, prefer the AI cleanup preset: |
| 30 | + |
| 31 | +```powershell |
| 32 | +EncodingFixTool path=. preset=delphi-ai scope=git-changed format=json |
| 33 | +``` |
| 34 | + |
| 35 | +If the executable is not on `PATH`, use a local build such as: |
| 36 | + |
| 37 | +```powershell |
| 38 | +.\bin\EncodingFixTool.exe path=. preset=delphi-ai scope=git-changed format=json |
| 39 | +``` |
| 40 | + |
| 41 | +3. Outside Git, use an explicit path and dry run first: |
| 42 | + |
| 43 | +```powershell |
| 44 | +EncodingFixTool path=.\src preset=delphi-ai format=json dry |
| 45 | +``` |
| 46 | + |
| 47 | +Run the same command without `dry` only after the reported scope is correct. |
| 48 | + |
| 49 | +## Read Results |
| 50 | + |
| 51 | +Treat the run as successful only when the process exits with code `0` and JSON `failed` is `0`. |
| 52 | + |
| 53 | +- `changed > 0`: inspect the relevant diffs before reporting done. |
| 54 | +- `skipped > 0`: usually expected for binary `.dfm`; mention it only when relevant. |
| 55 | +- `failed > 0` or exit code `1`: stop and report the file-level failure. |
| 56 | +- Exit code `2`: fix the missing `path` and rerun. |
| 57 | + |
| 58 | +## Verify |
| 59 | + |
| 60 | +After cleanup: |
| 61 | + |
| 62 | +```powershell |
| 63 | +git diff --stat |
| 64 | +git ls-files --eol *.pas *.dpr *.dpk *.inc *.dfm *.dproj |
| 65 | +``` |
| 66 | + |
| 67 | +Then continue with the repo's normal Delphi build/test gates. EncodingFixTool only fixes encoding and line endings. |
| 68 | + |
| 69 | +## Reporting Pattern |
| 70 | + |
| 71 | +Keep the final note short and evidence-based: |
| 72 | + |
| 73 | +```text |
| 74 | +Ran EncodingFixTool with preset=delphi-ai scope=git-changed format=json. |
| 75 | +Result: scanned=4, changed=2, skipped=1, failed=0. |
| 76 | +Checked git diff --stat and continued with the repo build/test gate. |
| 77 | +``` |
| 78 | + |
| 79 | +If the tool was not run, state why: for example, no Delphi files were touched, the worktree had unrelated changes, or EncodingFixTool was unavailable. |
| 80 | + |
| 81 | +## More Detail |
| 82 | + |
| 83 | +Read `references/encodingfix-tool.md` only when you need command details, preset precedence, dry-run behavior, install/copy notes, or examples for non-standard scopes. |
0 commit comments