/scout:scout-locfrom scout
Counts lines of code per language and path using cloc, with git history replay. Handles include/exclude filters and config files for multi-metric queries.
Ships in scout. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
scout locCount lines of code per language and path, in the current working tree or across commits. Runs cloc under the hood.
Run scout loc --help for flags — it is the source of truth. This file covers what the help does not say.
cloc must be on $PATH: brew install cloc, or apt-get install -y cloc. Language names are cloc's own spelling — Swift, Objective-C, C/C++ Header. A misspelled language is not an error, it is a zero.
Use a config whenever you want more than one include/exclude combination — the CLI flags describe a single metric.
CLI and config don't merge here. Positional languages take the whole CLI branch and the config's metrics are ignored; a config file takes its own branch and --include / --exclude are dropped. Both failure modes are silent: scout loc Swift --config loc.json measures Swift | . → 0, and scout loc --config loc.json --include Sources quietly ignores the flag. Pick one side. --name-template is the only flag that reaches config metrics.
{
"metrics": [
{ "languages": ["Swift"], "include": ["Sources"], "exclude": [".build", "Tests", "Vendor"] },
{ "languages": ["Swift"], "include": ["Tests"], "exclude": [".build"], "nameTemplate": "Tests" },
{ "languages": ["Swift", "Objective-C"], "include": ["LegacyModule"], "exclude": [".build"], "commits": ["abc123"] }
],
"git": { "repoPath": "/path/to/repo", "clean": true }
}
include is required, and it matches directories by suffix everywhereThis is the one thing to get right.
include is not a path and not a glob. Every directory under --repo-path whose full path string ends with one of the strings is measured, at any depth, and the results are summed. It is a string suffix, not a path component: --include App also matches MyApp and LegacyApp, and --include ttings matches Sources/BuildSettings.
Three consequences, all verified on this repository:
include measures nothing. scout loc Swift with no --include reports 0, silently. Always pass --include.--include Sources on a checkout with a populated .build sweeps in every dependency's Sources folder — measured on this repository, that inflated the answer by more than two orders of magnitude. Always exclude .build, and whatever else holds a copy of the tree: Pods, DerivedData, Carthage, node_modules, extra worktrees.Tests/LOCTests/Samples/Sources matched Sources too and its lines were added on top.exclude drops a matched folder when one of its strings appears anywhere in the folder path, case-insensitively — so .build and Pods work as written, no globs needed.
Sanity-check the first number of a new metric against cloc --include-lang=Swift <dir> before building a series on it. An order-of-magnitude gap means the include picked up a tree you didn't mean.
Results are keyed by a rendered name, not by language — which is why two metrics with the same languages need different names. The default template is %langs% | %include%, and the placeholders expand to comma-separated lists. Worth knowing because it is how a broken metric announces itself: empty languages renders Unknown, empty include renders ., empty exclude renders an empty string — a result named Swift | . is the silent-zero case below, not a real measurement.
Priority is the usual one: --name-template beats metrics[].nameTemplate beats the default.
Pick stable names before running history — the name is the join key of the whole time series, and renaming a metric later splits the chart in two.
{
"commit": "abc1234def5678",
"date": "2025-01-15T07:30:00Z",
"results": [
{ "metric": "Swift | Sources", "linesOfCode": 48500 }
]
}
linesOfCode is cloc's code count — comments and blank lines excluded.
scout loc Swift --include Sources --exclude .build Tests --output /tmp/loc.json
jq -r '.[] | .results[] | "\(.metric)\t\(.linesOfCode)"' /tmp/loc.json
No --commits, so scout reads the files as they are — uncommitted changes included — and changes nothing in git: no checkout, no clean. Start here; replay history only when the question is about change over time.
jq -r '.[] | .date as $d | .results[] | [$d, .metric, .linesOfCode] | @csv' /tmp/loc.json
jq '.[-1].results | (map(select(.metric == "Tests") | .linesOfCode) | add)
/ (map(select(.metric == "Swift | Sources") | .linesOfCode) | add)' /tmp/loc.json
Give each module its own metric in the config, with nameTemplate set to the module name, and one scout loc run covers them all per checkout.
cloc installed and report the failure as "no code found".--include — the answer is a silent 0..build, Pods, DerivedData and other copies of the tree; they are counted otherwise.include/exclude — matching is suffix and substring. Globs belong to scout-build-settings.linesOfCode with a file count from scout-files as if they measured the same thing.scout-files — how many files rather than how many lines.scout (umbrella) — output envelope, per-metric commits, --git-clean footgun, detached HEAD after a historical run.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/scoutPlan and run a multi-metric measurement of a repository with the `scout` CLI, and pick which subcommand a request needs. Trigger on cross-cutting intent rather than a single number, e.g. "build a dashboard of codebase metrics", "measure how this repo changed over two years", "I need numbers for the UIKit-to-SwiftUI migration from several angles", "set up a monthly metrics job in CI", "what can we even measure about this codebase?", "which scout command do I want for this?", "collect these metrics at the same commits so the series line up", "how do I run this over history without wrecking my working copy?". Also the place for anything shared across metrics — replaying over git history, the output envelope, config vs CLI precedence, and the ways a historical run damages a working checkout. Single-axis questions belong to `scout-types`, `scout-files`, `scout-pattern`, `scout-loc` or `scout-build-settings`./scout-build-settingsExtract Xcode build settings per target with `scout build-settings`. Trigger when the question is about project configuration rather than source code, e.g. "which Swift version do our targets build with?", "what is our minimum iOS deployment target?", "which modules still have strict concurrency off?", "when did we move to Swift 6?", "show SWIFT_VERSION per target across the last year". Discovers `.xcodeproj` files by glob and can run setup commands first, so Tuist and XcodeGen projects work too. macOS only.npx claudepluginhub dodobrands/scout --plugin scoutOther plugins' skills for the same job