Install any skill in seconds. Free to start, no credit card required.
Get Started Free →When a code-behind transform must locate the class body opening brace (`{`) to inject fields or members, it must use `[^{]*\{` **not** `\s*\{` between the class name and the brace.
.claude/skills/fritzandfriends-skill-code-behind-transform-class-body-location-pattern/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-15 | ✗→✓ | ▲ Improved | -53% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 73% | 0% |
| case-13 | ✗→✓ | ▲ Improved | -40% | 0% |
| case-17 | ✗→✓ | ▲ Improved | -35% | 0% |
| case-18 | ✗→✓ | ▲ Improved | -25% | 0% |
When a code-behind transform must locate the class body opening brace ({) to inject fields or members, it must use [^{]*\{ not \s*\{ between the class name and the brace.
Code-behind transforms run in Order sequence. Earlier transforms (e.g., BaseClassStripTransform at Order 200) modify the class declaration before later transforms see it. By Order 220+, a typical Page class looks like:
csharppublic partial class ShoppingCart : WebFormsPageBase {
A regex like partial\s+class\s+\w+\s*\{ fails to match this because : WebFormsPageBase\n is not \s*. The transform silently returns the content unchanged — no injection happens, no error is raised.
csharp// WRONG — fails when base class or interface list is present private static readonly Regex ClassOpenRegex = new( @"partial\s+class\s+\w+\s*\{", RegexOptions.Compiled); // CORRECT — [^{]* skips base class, interfaces, newlines, anything before { private static readonly Regex ClassOpenRegex = new( @"partial\s+class\s+\w+[^{]*\{", RegexOptions.Compiled);
[^{]* matches : WebFormsPageBase, : Base, IInterface, spaces, newlines — everything up to (but not including) the first {.
When authoring such a transform, always include these three test shapes:
public partial class Foo { (baseline)public partial class Foo : WebFormsPageBase { public partial class Foo : WebFormsPageBase\n{ComponentRefCodeBehindTransform (Order 220) injects @ref backing fields. It was broken from inception because its ClassOpenRegex used \s*\{. After BaseClassStripTransform (Order 200) added : WebFormsPageBase, the regex never matched — causing 15+ CS0103 errors per page in WingtipToys Run 80.
Fix commit: ClassOpenRegex changed from \s*\{ to [^{]*\{ (2026-05-15).
Other measured skills in the registry, with their headline benchmark lift.