CSharpier — format C# (all files)
When to use
- User wants all
*.csfiles formatted, or a directory / project run through CSharpier. - Before handoff or before commit when
.csis in scope (format-before-handoff-and-commit.mdc).
Preconditions
- CSharpier is installed: global tool and/or local
dotnet tool(manifest next to the repo). - Run from the repository root that contains the code (for Unity: often the folder above
Assets, e.g.GridDungeonECS), unless the user names a different root.
Commands (pick what works in the environment)
Local tool — if
dotnet-tools.jsonexists at repo root:dotnet tool restore dotnet csharpier format .Global tool on PATH — common when the repo has no manifest (many Unity projects):
csharpier format .Single file or subtree:
dotnet csharpier format path/to/File.cs csharpier format path/to/File.cs dotnet csharpier format Assets/SomeFolder csharpier format Assets/SomeFolder
format . recursively formats .cs files per CSharpier configuration (e.g. .csharpierrc, csharpier.yaml, .editorconfig).
Agent workflow
- Confirm root: Prefer the workspace’s git/Plastic root (parent of
Assetsfor Unity projects) so formatting matches CI/editor. - Run via Shell from that root:
- If
dotnet-tools.jsonis present:dotnet tool restorethendotnet csharpier format .(or scoped paths). - Else try
dotnet csharpier format .once; if it fails (“Could not execute”, tool not found), runcsharpier format .(global).
- If
- If both fail: report that
dotnet tool install csharpier --globalor adding a local tool (dotnet new tool-manifest+dotnet tool install csharpier) is required; do not silently substitute another formatter. - Scope: “Format all
.cs” →format .from chosen root. Do not limit toAssetsonly unless the user asked to scope there.
Notes
- CSharpier does not format
.uxml,.shader, etc. — C# only. - Windows PowerShell does not treat
&&as a command separator on older versions. Use;or runSet-Location "d:\path\to\repo"; csharpier format .(or separate Shell invocations) instead ofcd path && csharpier ….