file-builder-expert

Author and fix C# code-generation templates using the Fluent CSharpFile builder API.

23|10|Updated Aug 31, 2017
One-click install
npx skills add https://github.com/IntentArchitect/Intent.Modules --skill file-builder-expert-intentarchitect
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: file-builder-expert
Source: https://github.com/IntentArchitect/Intent.Modules/tree/main/Tests/ModuleBuilderSkills/.opencode/skills/file-builder-expert
Command: npx skills add https://github.com/IntentArchitect/Intent.Modules --skill file-builder-expert-intentarchitect

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing Intent Architect templates that emit C# via the CSharpFile fluent builder involves many non-obvious rules — callback priority bands, type resolution through GetTypeName/UseType, sibling placement of else/catch blocks, and obsolete API traps — and mistakes surface as build lifecycle exceptions or uncompilable generated code. ## Core Features & Use Cases - Template authoring rules: Enforces the required contract (CSharpTemplateBase<TModel>, ICSharpFileBuilderTemplate, DefineFileConfig/TransformText) and constructor-based CSharpFile initialization. - Lifecycle and type-resolution guidance: Covers OnBuild/AfterBuild priority bands (0/100/500/1000), single-file vs file-per-model namespace resolution, and DI parameter injection via IntroduceReadonlyField. - Troubleshooting reference: Indexes 11 indexed failure modes such as "Build() needs to be called before ToString()", double semicolons from AddReturn, and FindMethod returning only the first overload. - Use Case: When converting a *TemplatePartial.cs to emit C# via CSharpFile, use this Skill to structure the constructor, register callbacks at correct priorities, and resolve model types without hardcoded namespaces. ## Quick Start Use the file-builder-expert skill to review my TemplatePartial.cs and convert it to emit C# through the CSharpFile fluent builder API.

Frequently Asked Questions about file-builder-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a C# template using the CSharpFile builder API?▼

Inherit from CSharpTemplateBase<TModel>, implement ICSharpFileBuilderTemplate, and initialize CSharpFile in the constructor with AddClass and related fluent calls. Implement DefineFileConfig() => CSharpFile.GetConfig() and TransformText() => CSharpFile.ToString() as the full required contract.

How do I resolve type names in Intent Architect templates?▼

Use GetTypeName(model) for model references, GetTypeName(templateId, model) for TemplateId-based references, and UseType("Namespace.Type") for framework types so usings are tracked automatically. Never use UseType for types represented in the Intent model.

Why does my template throw 'Build() needs to be called before ToString()'?▼

This happens when TransformText runs before the builder lifecycle, usually because ICSharpFileBuilderTemplate is not implemented on the template class. Implement that interface and keep TransformText as return CSharpFile.ToString() only.

Why is the using directive missing for a single-file template type?▼

AddTypeSource(templateId) only works for file-per-model templates because it resolves types by model lookup. For single-file templates, find the template instance via ExecutionContext.FindTemplateInstance<IClassProvider> inside an OnBuild callback and add its namespace with file.AddUsing.

When should I not use the CSharpFile builder approach?▼

Do not use it for templates that emit Markdown or plain text output, or for designer-model and script changes. It applies only to templates generating C# source through the fluent builder, and requires the model shape (single-file vs file-per-model) already decided.