name: unified-style-guide description: "Establish and enforce a consistent C# coding style for Unity projects. Includes .editorconfig generation and architectural guidelines." version: 2.0.0 tags: ["style-guide", "csharp", "architecture", ".editorconfig", "best-practices"] argument-hint: "action='install' OR type='config'" disable-model-invocation: false user-invocable: true allowed-tools: - run_command - list_dir - write_to_file requirements: unity_version: ">=6.0" render_pipeline: "Any" dependencies: [] context_discovery: check_unity_version: true check_render_pipeline: false scan_manifest_for: [] performance_budget: gc_alloc_per_frame: "0 bytes target in hot paths" max_update_cost: "O(n) - profiler-guided" tdd_first: true
Unified Style Guide
Overview
Defines the "North Star" for code quality and consistency. Enforces naming conventions, formatting rules, and architectural standards to ensure the codebase remains maintainable and readable by any team member.
When to Use
- Use at the start of a project to set ground rules.
- Use during Code Reviews to cite standards.
- Use when refactoring legacy code.
- Use to configure IDEs (Rider, VS Code, Visual Studio).
- Use to resolve "Tab vs Space" debates.
Core Rules
| Category | Rule | Example |
|---|---|---|
| Public Fields | PascalCase | public int Health; |
| Private Fields | _camelCase | private int _currentHealth; |
| Methods | PascalCase | public void TakeDamage() { } |
| Interfaces | IPrefix | public interface IDamageable { } |
| Classes | PascalCase | public class PlayerController : MonoBehaviour |
| Serialization | Force private | [SerializeField] private int _speed; |
| Braces | Allman (New Line) | if (true){ ... } |
Architecture Standards
- SOLID Principles: Code should adhere to SOLID where applicable in Unity.
- Composition over Inheritance: Prefer
GetComponentand Interfaces over deep class hierarchies. - Separation of Concerns: Logic (C#) should be separate from View (Unity UI/Prefab).
- No "Manager" Bloat: Avoid massive
GameManager.csfiles; break intoScoreSystem,AudioSystem, etc.
Best Practices
- ✅ Use
[SerializeField] privateinstead ofpublicvariables. - ✅ Use
Regionblocks sparingly (only for massive files or interface implementations). - ✅ Use
namespacefor every script (e.g.,Game.Gameplay.Player). - ✅ Remove unused
usingstatements. - ❌ NEVER use
GameObject.Find()inUpdate(). - ❌ NEVER leave empty Unity messages (
Update() {}) - overhead is non-zero. - ❌ NEVER make fields
publicjust to see them in Inspector (use[SerializeField]).
Few-Shot Examples
Example 1: Installing Config
User: "Setup the style guide."
Agent:
# Writes .editorconfig to project root
write_to_file(TargetFile=".editorconfig", Content=TemplateContent...)
Example 2: Code Correction
User: "Fix this script style."
Code (Before):
public int speed = 10;
void Update() {
if(speed>5) {
transform.Translate(0,0,1);
}
}
Agent (After):
[SerializeField] private int _speed = 10;
private void Update()
{
if (_speed > 5)
{
transform.Translate(Vector3.forward);
}
}
TDD Contract
⚠️ Legacy Skill — Refactor Pending Este skill NO tiene tests automatizados aún. El siguiente boilerplate es un punto de partida.
// Escribe estos tests ANTES de implementar:
// Test 1: should [expected behavior] when [condition]
[Test]
public void UnifiedStyleGuide_Should{ExpectedBehavior}_When{Condition}()
{{
// Arrange
// TODO: Setup test fixtures
// Act
// TODO: Execute system under test
// Assert
Assert.Fail("Not implemented — write test first");
}}
// Test 2: should handle [edge case]
[Test]
public void UnifiedStyleGuide_ShouldHandle{EdgeCase}()
{{
// Arrange
// TODO: Setup edge case scenario
// Act
// TODO: Execute
// Assert
Assert.Fail("Not implemented");
}}
// Test 3: should throw when [invalid input]
[Test]
public void UnifiedStyleGuide_ShouldThrow_When{InvalidInput}()
{{
// Arrange
var invalidInput = default;
// Act & Assert
Assert.Throws<Exception>(() => {{ /* execute */ }});
}}
Pasos para completar el TDD:
- Descomenta los tests above
- Implementa la funcionalidad mínima para que compile
- Ejecuta los tests — deben fallar (RED)
- Implementa la funcionalidad real
- Verifica que los tests pasen (GREEN)
- Refactorea manteniendo los tests verdes
Nota: Este skill fue marcado como tdd_first: false durante la auditoría v2.0.1. La sección TDD fue agregada automáticamente pero requiere customización manual para reflejar el comportamiento real del skill.
Related Skills
@automated-unit-testing- Testing follows style@custom-editor-scripting- Editor tools style
Converted and distributed by TomeVault — claim your Tome and manage your conversions.