|
| 1 | +--- |
| 2 | +name: mcaf-dotnet-cloc |
| 3 | +description: "Use the open-source free `cloc` tool for line-count, language-mix, and diff statistics in .NET repositories. Use when a repo needs C# and solution footprint metrics, branch-to-branch LOC comparison, or repeatable code-size reporting in local workflows and CI." |
| 4 | +compatibility: "Requires a repository with .NET source files or a Git checkout; respects the repo's `AGENTS.md` commands first." |
| 5 | +--- |
| 6 | + |
| 7 | +# MCAF: .NET cloc |
| 8 | + |
| 9 | +## Trigger On |
| 10 | + |
| 11 | +- the repo wants `cloc` |
| 12 | +- the team needs repeatable LOC, language, or branch diff statistics for a .NET repo |
| 13 | +- the user asks about C# codebase size, solution composition, or code-count deltas between refs |
| 14 | + |
| 15 | +## Value |
| 16 | + |
| 17 | +- produce a concrete project delta: code, docs, config, tests, CI, or review artifact |
| 18 | +- reduce ambiguity through explicit planning, verification, and final validation skills |
| 19 | +- leave reusable project context so future tasks are faster and safer |
| 20 | + |
| 21 | +## Do Not Use For |
| 22 | + |
| 23 | +- judging developer productivity from raw LOC |
| 24 | +- replacing behavioral verification, architecture review, or complexity analysis |
| 25 | +- counting generated or vendored files without an explicit reason |
| 26 | + |
| 27 | +## Inputs |
| 28 | + |
| 29 | +- the nearest `AGENTS.md` |
| 30 | +- target repository, solution, project, or subtree |
| 31 | +- the question being answered: footprint, composition, diff, or trend |
| 32 | + |
| 33 | +## Quick Start |
| 34 | + |
| 35 | +1. Read the nearest `AGENTS.md` and confirm scope and constraints. |
| 36 | +2. Run this skill's `Workflow` through the `Ralph Loop` until outcomes are acceptable. |
| 37 | +3. Return the `Required Result Format` with concrete artifacts and verification evidence. |
| 38 | + |
| 39 | +## Workflow |
| 40 | + |
| 41 | +1. Choose the counting mode deliberately: |
| 42 | + - `--vcs=git` for repo-respecting counts |
| 43 | + - path-based counting for bounded folders |
| 44 | + - `--git --diff <base> <head>` for change deltas |
| 45 | +2. Prefer `.NET`-relevant views first: |
| 46 | + - C# footprint |
| 47 | + - test versus production footprint |
| 48 | + - solution language mix such as C#, Razor, XML, JSON, YAML, and MSBuild files |
| 49 | +3. Exclude noise before trusting the numbers: |
| 50 | + - `bin` |
| 51 | + - `obj` |
| 52 | + - `.git` |
| 53 | + - vendored or generated folders when they are not part of the decision |
| 54 | +4. Use machine-readable output when the numbers feed docs, CI, or follow-up automation: |
| 55 | + - `--json` |
| 56 | + - `--csv` |
| 57 | + - `--yaml` |
| 58 | + - `--md` |
| 59 | +5. Treat `cloc` as a sizing and comparison tool, not as evidence that the design is good. |
| 60 | +6. When using diff mode, compare named refs that match the review question: |
| 61 | + - `origin/main..HEAD` |
| 62 | + - release branch versus main |
| 63 | + - before and after a refactor |
| 64 | +7. After any code cleanup based on `cloc` findings, run the repo's normal quality pass. |
| 65 | + |
| 66 | +## Bootstrap When Missing |
| 67 | + |
| 68 | +If `cloc` is not available yet: |
| 69 | + |
| 70 | +1. Detect current state: |
| 71 | + - `command -v cloc` |
| 72 | + - `cloc --version` |
| 73 | + - `perl --version` |
| 74 | +2. Choose the install path deliberately: |
| 75 | + - macOS with Homebrew: `brew install cloc` |
| 76 | + - Debian or Ubuntu: `sudo apt install cloc` |
| 77 | + - Red Hat or older Fedora family: `sudo yum install cloc` |
| 78 | + - Fedora or newer Red Hat family: `sudo dnf install cloc` |
| 79 | + - npm fallback: `npm install -g cloc` |
| 80 | + - Windows with Chocolatey: `choco install cloc` |
| 81 | + - Windows with Scoop: `scoop install cloc` |
| 82 | + - Docker fallback: `docker run --rm -v $PWD:/tmp aldanial/cloc .` |
| 83 | +3. If package-manager builds are not acceptable, install from the latest upstream release or source and verify with `cloc --version`. |
| 84 | +4. Record exact counting commands in `AGENTS.md`, for example: |
| 85 | + - `cloc --vcs=git --include-lang="C#,MSBuild,JSON,XML,YAML"` |
| 86 | + - `cloc --by-file --vcs=git --include-lang="C#"` |
| 87 | + - `cloc --git --diff origin/main HEAD --include-lang="C#"` |
| 88 | +5. Run one bounded command and return `status: configured` or `status: improved`. |
| 89 | +6. If the repo intentionally uses another code-count tool and does not want `cloc`, return `status: not_applicable`. |
| 90 | + |
| 91 | +## Deliver |
| 92 | + |
| 93 | +- repeatable LOC and language-mix reporting for .NET repos |
| 94 | +- explicit include and exclude rules |
| 95 | +- branch-diff or bounded-scope commands that answer a concrete engineering question |
| 96 | + |
| 97 | +## Validate |
| 98 | + |
| 99 | +- counts match the intended source boundary instead of including build output noise |
| 100 | +- command choice matches the reporting question |
| 101 | +- any automation or docs that consume the numbers can rerun the same command |
| 102 | +- `cloc` is used as context, not as a substitute for tests or design review |
| 103 | + |
| 104 | +## Ralph Loop |
| 105 | + |
| 106 | +Use the Ralph Loop for every task, including docs, architecture, testing, and tooling work. |
| 107 | + |
| 108 | +1. Plan first (mandatory): |
| 109 | + - analyze current state |
| 110 | + - define target outcome, constraints, and risks |
| 111 | + - write a detailed execution plan |
| 112 | + - list final validation skills to run at the end, with order and reason |
| 113 | +2. Execute one planned step and produce a concrete delta. |
| 114 | +3. Review the result and capture findings with actionable next fixes. |
| 115 | +4. Apply fixes in small batches and rerun the relevant checks or review steps. |
| 116 | +5. Update the plan after each iteration. |
| 117 | +6. Repeat until outcomes are acceptable or only explicit exceptions remain. |
| 118 | +7. If a dependency is missing, bootstrap it or return `status: not_applicable` with explicit reason and fallback path. |
| 119 | + |
| 120 | +### Required Result Format |
| 121 | + |
| 122 | +- `status`: `complete` | `clean` | `improved` | `configured` | `not_applicable` | `blocked` |
| 123 | +- `plan`: concise plan and current iteration step |
| 124 | +- `actions_taken`: concrete changes made |
| 125 | +- `validation_skills`: final skills run, or skipped with reasons |
| 126 | +- `verification`: commands, checks, or review evidence summary |
| 127 | +- `remaining`: top unresolved items or `none` |
| 128 | + |
| 129 | +For setup-only requests with no execution, return `status: configured` and exact next commands. |
| 130 | + |
| 131 | +## Load References |
| 132 | + |
| 133 | +- read `references/cloc.md` first |
| 134 | + |
| 135 | +## Example Requests |
| 136 | + |
| 137 | +- "Add cloc reporting to this .NET repo." |
| 138 | +- "Compare code size between main and this branch." |
| 139 | +- "Count C# versus test footprint in this solution." |
| 140 | +- "Give me a machine-readable line-count report for CI." |
0 commit comments