Skip to content

Commit 40e08b9

Browse files
committed
Add mcaf-dotnet-cloc skill
1 parent ccda973 commit 40e08b9

File tree

4 files changed

+291
-1
lines changed

4 files changed

+291
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Platform-specific bundles can stay small and still be explicit.
115115
For example, a typical .NET repo baseline can install `mcaf-dotnet` as the entry skill, `mcaf-dotnet-features`, `mcaf-solution-governance`, `mcaf-testing`, exactly one of `mcaf-dotnet-xunit`, `mcaf-dotnet-tunit`, or `mcaf-dotnet-mstest`, plus `mcaf-dotnet-quality-ci`, `mcaf-dotnet-complexity`, `mcaf-solid-maintainability`, `mcaf-architecture-overview`, and `mcaf-ci-cd`.
116116
In that setup, `mcaf-dotnet` knows when to open the more specific .NET skills, the repo-root lowercase `.editorconfig` is the default source of truth for formatting and analyzer severity, and `AGENTS.md` records the exact `dotnet build`, `dotnet test`, `dotnet format`, `analyze`, and coverage commands. Nested `.editorconfig` files are allowed when they serve a clear subtree-specific purpose, such as stricter domain rules, generated-code handling, test-specific conventions, or legacy-code containment.
117117
For .NET code changes, the task is not done when tests are green if the repo also configured formatters, analyzers, coverage, architecture tests, or security gates. Agents should run the repo-defined post-change quality pass before completion.
118-
If the repo standardizes on concrete tools, install the matching tool skills as well. Typical open or free .NET additions include `mcaf-dotnet-format`, `mcaf-dotnet-code-analysis`, `mcaf-dotnet-analyzer-config`, `mcaf-dotnet-stylecop-analyzers`, `mcaf-dotnet-roslynator`, `mcaf-dotnet-meziantou-analyzer`, `mcaf-dotnet-coverlet`, `mcaf-dotnet-quickdup`, `mcaf-dotnet-reportgenerator`, `mcaf-dotnet-stryker`, `mcaf-dotnet-netarchtest`, `mcaf-dotnet-archunitnet`, `mcaf-dotnet-semgrep`, and `mcaf-dotnet-csharpier`. `mcaf-dotnet-codeql` stays available, but should be chosen only when its hosting and licensing model fits the repository.
118+
If the repo standardizes on concrete tools, install the matching tool skills as well. Typical open or free .NET additions include `mcaf-dotnet-format`, `mcaf-dotnet-code-analysis`, `mcaf-dotnet-analyzer-config`, `mcaf-dotnet-stylecop-analyzers`, `mcaf-dotnet-roslynator`, `mcaf-dotnet-meziantou-analyzer`, `mcaf-dotnet-cloc`, `mcaf-dotnet-coverlet`, `mcaf-dotnet-quickdup`, `mcaf-dotnet-reportgenerator`, `mcaf-dotnet-stryker`, `mcaf-dotnet-netarchtest`, `mcaf-dotnet-archunitnet`, `mcaf-dotnet-semgrep`, and `mcaf-dotnet-csharpier`. `mcaf-dotnet-codeql` stays available, but should be chosen only when its hosting and licensing model fits the repository.
119119

120120
### 2.5 Context Rules
121121

TUTORIAL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Add tool-specific .NET skills only when the repo standardizes on them:
140140
<!-- MCAF:DOTNET-OPTIONAL-SKILLS-BEGIN -->
141141
- `mcaf-dotnet-analyzer-config`
142142
- `mcaf-dotnet-archunitnet`
143+
- `mcaf-dotnet-cloc`
143144
- `mcaf-dotnet-code-analysis`
144145
- `mcaf-dotnet-codeql`
145146
- `mcaf-dotnet-coverlet`
@@ -170,6 +171,7 @@ The website build generates this list from the actual folders under `skills/`.
170171
- `mcaf-dotnet`[Folder](https://github.com/managedcode/MCAF/blob/main/skills/mcaf-dotnet), [Raw SKILL](https://raw.githubusercontent.com/managedcode/MCAF/main/skills/mcaf-dotnet/SKILL.md)
171172
- `mcaf-dotnet-analyzer-config`[Folder](https://github.com/managedcode/MCAF/blob/main/skills/mcaf-dotnet-analyzer-config), [Raw SKILL](https://raw.githubusercontent.com/managedcode/MCAF/main/skills/mcaf-dotnet-analyzer-config/SKILL.md)
172173
- `mcaf-dotnet-archunitnet`[Folder](https://github.com/managedcode/MCAF/blob/main/skills/mcaf-dotnet-archunitnet), [Raw SKILL](https://raw.githubusercontent.com/managedcode/MCAF/main/skills/mcaf-dotnet-archunitnet/SKILL.md)
174+
- `mcaf-dotnet-cloc`[Folder](https://github.com/managedcode/MCAF/blob/main/skills/mcaf-dotnet-cloc), [Raw SKILL](https://raw.githubusercontent.com/managedcode/MCAF/main/skills/mcaf-dotnet-cloc/SKILL.md)
173175
- `mcaf-dotnet-code-analysis`[Folder](https://github.com/managedcode/MCAF/blob/main/skills/mcaf-dotnet-code-analysis), [Raw SKILL](https://raw.githubusercontent.com/managedcode/MCAF/main/skills/mcaf-dotnet-code-analysis/SKILL.md)
174176
- `mcaf-dotnet-codeql`[Folder](https://github.com/managedcode/MCAF/blob/main/skills/mcaf-dotnet-codeql), [Raw SKILL](https://raw.githubusercontent.com/managedcode/MCAF/main/skills/mcaf-dotnet-codeql/SKILL.md)
175177
- `mcaf-dotnet-complexity`[Folder](https://github.com/managedcode/MCAF/blob/main/skills/mcaf-dotnet-complexity), [Raw SKILL](https://raw.githubusercontent.com/managedcode/MCAF/main/skills/mcaf-dotnet-complexity/SKILL.md)

skills/mcaf-dotnet-cloc/SKILL.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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."
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# cloc for .NET Repositories
2+
3+
## What It Is
4+
5+
`cloc` counts blank lines, comment lines, and physical lines of code across many languages. In a .NET repository, it is useful for footprint reporting, solution composition, branch diffs, and bounded-scope comparisons.
6+
7+
Use it to answer specific questions, not to rate developer output.
8+
9+
## Installation Paths
10+
11+
Use the official upstream install paths and keep the chosen command in `AGENTS.md`:
12+
13+
- macOS with Homebrew:
14+
15+
```bash
16+
brew install cloc
17+
```
18+
19+
- Debian or Ubuntu:
20+
21+
```bash
22+
sudo apt install cloc
23+
```
24+
25+
- Red Hat or older Fedora family:
26+
27+
```bash
28+
sudo yum install cloc
29+
```
30+
31+
- Fedora or newer Red Hat family:
32+
33+
```bash
34+
sudo dnf install cloc
35+
```
36+
37+
- npm fallback:
38+
39+
```bash
40+
npm install -g cloc
41+
```
42+
43+
- Windows with Chocolatey:
44+
45+
```powershell
46+
choco install cloc
47+
```
48+
49+
- Windows with Scoop:
50+
51+
```powershell
52+
scoop install cloc
53+
```
54+
55+
- Docker fallback:
56+
57+
```bash
58+
docker run --rm -v $PWD:/tmp aldanial/cloc .
59+
```
60+
61+
If package-manager builds are not acceptable, use the latest upstream release from `AlDanial/cloc` and verify:
62+
63+
```bash
64+
cloc --version
65+
```
66+
67+
## Good Default Commands
68+
69+
Count tracked files in the current repository:
70+
71+
```bash
72+
cloc --vcs=git
73+
```
74+
75+
Count common .NET repo languages only:
76+
77+
```bash
78+
cloc --vcs=git --include-lang="C#,MSBuild,JSON,XML,YAML"
79+
```
80+
81+
Count only C# by file:
82+
83+
```bash
84+
cloc --by-file --vcs=git --include-lang="C#"
85+
```
86+
87+
Compare branch delta for C#:
88+
89+
```bash
90+
cloc --git --diff origin/main HEAD --include-lang="C#"
91+
```
92+
93+
Count a bounded subtree:
94+
95+
```bash
96+
cloc src --include-lang="C#,MSBuild,JSON,XML,YAML"
97+
```
98+
99+
## Excludes That Usually Matter
100+
101+
Start with repo-respecting or explicit excludes so the numbers are not polluted by build artifacts:
102+
103+
- `bin`
104+
- `obj`
105+
- `.git`
106+
- vendored folders
107+
- generated folders when they are not part of the question
108+
109+
Example:
110+
111+
```bash
112+
cloc . --exclude-dir=bin,obj,.git
113+
```
114+
115+
## Output Modes
116+
117+
Use machine-readable output when the numbers feed docs or automation:
118+
119+
- `--json`
120+
- `--csv`
121+
- `--yaml`
122+
- `--md`
123+
- `--xml`
124+
125+
Example:
126+
127+
```bash
128+
cloc --vcs=git --include-lang="C#" --json
129+
```
130+
131+
## When It Helps
132+
133+
Use `cloc` when you need:
134+
135+
- a quick footprint of production versus test code
136+
- a branch-to-branch size diff after a refactor
137+
- a codebase language mix for docs or governance
138+
- a stable command that humans and CI can rerun
139+
140+
## When It Does Not Help
141+
142+
Do not use `cloc` to conclude that:
143+
144+
- a larger change is better or worse by itself
145+
- a smaller file is automatically simpler
146+
- test quality is good because test LOC is high
147+
148+
Pair `cloc` with the repo's real verification flow: tests, analyzers, architecture checks, and maintainability review.

0 commit comments

Comments
 (0)