@hxp-tools/codedna 0.0.0-stage → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/codedna.js ADDED
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Installs the codedna skill into supported coding-agent skill directories.
5
+ // Thin Node wrapper around install.sh so `npx @hxp-tools/codedna` works.
6
+
7
+ const { spawnSync } = require('child_process');
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const ROOT = path.resolve(__dirname, '..');
12
+ const INSTALLER = path.join(ROOT, 'install.sh');
13
+ const PKG = require('../package.json');
14
+
15
+ const COLORS = {
16
+ reset: '\x1b[0m',
17
+ bold: '\x1b[1m',
18
+ dim: '\x1b[2m',
19
+ cyan: '\x1b[36m',
20
+ green: '\x1b[32m',
21
+ red: '\x1b[31m',
22
+ };
23
+
24
+ function c(color, text) {
25
+ return COLORS[color] + text + COLORS.reset;
26
+ }
27
+
28
+ function usage() {
29
+ console.log(`
30
+ ${c('bold', 'codedna')} ${c('dim', 'v' + PKG.version)}
31
+ Fingerprint a codebase so AI contributions match the author.
32
+
33
+ ${c('bold', 'Usage')}
34
+ npx @hxp-tools/codedna@latest [all|claude|codex|cursor|windsurf]
35
+ npx @hxp-tools/codedna@latest --help
36
+
37
+ ${c('bold', 'Targets')}
38
+ all Install every registry-supported target (default)
39
+ claude Claude Code (~/.claude/skills/codedna)
40
+ codex Codex (~/.codex/skills/codedna)
41
+ cursor Cursor (~/.cursor/skills/codedna)
42
+ windsurf Windsurf (~/.codeium/windsurf/skills/codedna)
43
+
44
+ ${c('bold', 'After install')}
45
+ Restart your coding agent, then ask:
46
+ build the codedna for this repo
47
+
48
+ ${c('bold', 'Requirements')}
49
+ Python 3.9+ on a POSIX host. Windows is not supported.
50
+ `);
51
+ }
52
+
53
+ function main(argv) {
54
+ const args = argv.slice(2);
55
+ if (args.includes('--help') || args.includes('-h')) {
56
+ usage();
57
+ return 0;
58
+ }
59
+ if (args.includes('--version') || args.includes('-v')) {
60
+ console.log(PKG.version);
61
+ return 0;
62
+ }
63
+
64
+ if (process.platform === 'win32') {
65
+ console.error(c('red', 'codedna does not support Windows.'));
66
+ console.error('Install from the GitHub release tarball on a POSIX host instead.');
67
+ return 2;
68
+ }
69
+
70
+ if (!fs.existsSync(INSTALLER)) {
71
+ console.error(c('red', 'install.sh missing from package.'));
72
+ return 2;
73
+ }
74
+
75
+ const target = args[0] || 'all';
76
+ console.log(c('cyan', 'codedna') + ' ' + c('dim', 'v' + PKG.version));
77
+ console.log(c('dim', 'Installing skill into: ' + target));
78
+ console.log('');
79
+
80
+ const result = spawnSync('sh', [INSTALLER, target], {
81
+ cwd: ROOT,
82
+ stdio: 'inherit',
83
+ env: process.env,
84
+ });
85
+
86
+ if (result.error) {
87
+ console.error(c('red', String(result.error.message || result.error)));
88
+ return 1;
89
+ }
90
+ if (result.status === 0) {
91
+ console.log('');
92
+ console.log(c('green', 'Next: restart your agent, then ask it to build the codedna.'));
93
+ console.log(c('dim', 'Docs: ' + (PKG.homepage || 'https://github.com/hannsxpeter/codedna')));
94
+ }
95
+ return result.status == null ? 1 : result.status;
96
+ }
97
+
98
+ process.exitCode = main(process.argv);
package/install.sh ADDED
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env sh
2
+ # Install the codedna skill into supported coding-agent skill directories.
3
+ #
4
+ # Usage:
5
+ # ./install.sh <all|claude|codex|cursor|windsurf>
6
+ #
7
+ # Override destinations with:
8
+ # CLAUDE_SKILLS_DIR=/path/to/skills ./install.sh claude
9
+ # CODEX_SKILLS_DIR=/path/to/skills ./install.sh codex
10
+ # CURSOR_SKILLS_DIR=/path/to/skills ./install.sh cursor
11
+ # WINDSURF_SKILLS_DIR=/path/to/skills ./install.sh windsurf
12
+
13
+ set -eu
14
+
15
+ unset CDPATH
16
+ SRC_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
17
+ VERSION=$(awk '/^Version: / { print $2; exit }' "$SRC_DIR/skill/SKILL.md")
18
+ TARGET="${1:-}"
19
+
20
+ install_skill() {
21
+ label=$1
22
+ dest=$2
23
+ stale_file=$3
24
+ skill_dest="$dest/codedna"
25
+
26
+ mkdir -p "$skill_dest/scripts"
27
+ cp "$SRC_DIR/skill/SKILL.md" "$skill_dest/SKILL.md"
28
+ cp "$SRC_DIR"/skill/scripts/*.py "$skill_dest/scripts/"
29
+ chmod +x "$skill_dest"/scripts/*.py
30
+
31
+ if [ -n "$stale_file" ] && [ -f "$dest/$stale_file" ]; then
32
+ rm -f "$dest/$stale_file"
33
+ echo "Removed stale bare-file install at $dest/$stale_file"
34
+ fi
35
+
36
+ echo "Installed codedna v$VERSION for $label to $skill_dest"
37
+ }
38
+
39
+ install_claude() {
40
+ install_skill "Claude Code" "${CLAUDE_SKILLS_DIR:-$HOME/.claude/skills}" codedna.md
41
+ }
42
+
43
+ install_codex() {
44
+ install_skill "Codex" "${CODEX_SKILLS_DIR:-${CODEX_HOME:-$HOME/.codex}/skills}" codedna.md
45
+ }
46
+
47
+ install_cursor() {
48
+ install_skill "Cursor" "${CURSOR_SKILLS_DIR:-$HOME/.cursor/skills}" ""
49
+ }
50
+
51
+ install_windsurf() {
52
+ install_skill "Windsurf/Cascade" "${WINDSURF_SKILLS_DIR:-$HOME/.codeium/windsurf/skills}" ""
53
+ }
54
+
55
+ usage() {
56
+ echo "Usage: ./install.sh <all|claude|codex|cursor|windsurf>" >&2
57
+ echo "" >&2
58
+ echo "Targets:" >&2
59
+ echo " all Install for Claude Code, Codex, Cursor, and Windsurf/Cascade" >&2
60
+ echo " claude Install for Claude Code" >&2
61
+ echo " codex Install for Codex" >&2
62
+ echo " cursor Install for Cursor" >&2
63
+ echo " windsurf Install for Windsurf/Cascade" >&2
64
+ }
65
+
66
+ case "$TARGET" in
67
+ "")
68
+ usage
69
+ exit 0
70
+ ;;
71
+ all)
72
+ install_claude
73
+ install_codex
74
+ install_cursor
75
+ install_windsurf
76
+ ;;
77
+ claude)
78
+ install_claude
79
+ ;;
80
+ codex)
81
+ install_codex
82
+ ;;
83
+ cursor)
84
+ install_cursor
85
+ ;;
86
+ windsurf | cascade)
87
+ install_windsurf
88
+ ;;
89
+ *)
90
+ usage
91
+ exit 2
92
+ ;;
93
+ esac
94
+
95
+ echo "Restart the target coding agent to pick it up."
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@hxp-tools/codedna",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.2.0",
4
+ "description": "Fingerprint a codebase's coding and prose style so AI contributions match the author. Stdlib-only Python skill for Claude Code, Codex, Cursor, and Windsurf.",
5
+ "bin": {
6
+ "codedna": "bin/codedna.js"
7
+ },
8
+ "scripts": {
9
+ "start": "node bin/codedna.js",
10
+ "test": "python3 -m unittest discover -s tests",
11
+ "pack:check": "npm pack --dry-run",
12
+ "release:check": "npm test && npm run pack:check",
13
+ "prepublishOnly": "npm run release:check"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "keywords": [
19
+ "code-style",
20
+ "ai",
21
+ "ai-agents",
22
+ "claude-code",
23
+ "codex",
24
+ "cursor",
25
+ "agent-skills",
26
+ "developer-tools",
27
+ "codedna",
28
+ "style-guide"
29
+ ],
30
+ "author": "hannsxpeter",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/hannsxpeter/codedna.git"
35
+ },
36
+ "homepage": "https://github.com/hannsxpeter/codedna#readme",
37
+ "bugs": {
38
+ "url": "https://github.com/hannsxpeter/codedna/issues"
39
+ },
40
+ "engines": {
41
+ "node": ">=18.0.0"
42
+ },
43
+ "files": [
44
+ "bin/",
45
+ "skill/",
46
+ "install.sh",
47
+ "assets/",
48
+ "README.md",
49
+ "LICENSE",
50
+ "CHANGELOG.md"
51
+ ]
52
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,286 @@
1
+ ---
2
+ name: codedna
3
+ description: Generate a "DNA profile" of a codebase's coding and repository-prose style (naming, comments, docs, messages, structure, error handling, and idioms), then use it so new or AI-written contributions match the existing author. Use this skill when the user wants code or repository prose to blend in, mimic a coding style, capture house conventions, build a style guide from existing work, onboard to an unfamiliar repo's conventions, or check code, docs, or a diff for AI tells. Triggers on phrases like "match my coding style", "make it look like I wrote it", "codedna", "capture the conventions", "style guide from the code", "why does this read as AI-generated", "genetic map of the code", "mimic the codebase", and on significant contributions to an existing repo where matching house style matters. Do not use it for general writing with no repository or author corpus.
4
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit
5
+ ---
6
+
7
+ # CodeDNA
8
+
9
+ Version: 1.2.0
10
+
11
+ ## What this is, and why it matters
12
+
13
+ AI-written code is usually correct but recognizably foreign. It carries tells: a comment on every line, variable names two words longer than the human would pick, a try/catch the author never would have wrapped, a helper extracted where the author inlines, cheerful comment prose where the author is terse. Individually small; together they read as "not written by the person whose name is on the rest of the repo."
14
+
15
+ CodeDNA closes that gap. It studies a codebase the way you would study a writer's voice, writes the conventions down in a profile, and uses that profile so future contributions match. This includes the prose inside a repository: comments, docs, errors, logs, test descriptions, and CLI text. The goal is not "good work in the abstract"; it is work that reads as if the original author wrote it.
16
+
17
+ One idea runs through everything: **most surface formatting is already enforced by tooling, so it is not where the fingerprint lives.** Indentation, quotes, and semicolons get rewritten the moment someone runs Prettier, Black, gofmt, or rustfmt. The fingerprint that distinguishes a person is in the choices no formatter touches: what they name things, how much they comment and in what voice, how big their functions get, early returns versus nested conditionals, how defensively they handle errors, and the small idioms they reuse. Spend your attention there.
18
+
19
+ ## Three modes
20
+
21
+ Read the user's intent and pick one.
22
+
23
+ - **Map** (default): scan a codebase and produce `CODEDNA.md`. Triggered by "capture the style", "build the codedna", "map this repo".
24
+ - **Match**: write new code that follows an existing `CODEDNA.md` so it blends in. Triggered by "add X in the style of this repo", "write this so it looks like I wrote it".
25
+ - **Check**: review code or repository prose (a diff, a file, pasted output) against `CODEDNA.md` and report where it betrays a different author. Triggered by "does this look AI-generated", "check this against the codedna".
26
+
27
+ If a repo has no `CODEDNA.md` yet and the user wants Match or Check, run Map first.
28
+
29
+ ---
30
+
31
+ ## Mode: Map
32
+
33
+ Work in layers, cheapest and most authoritative first.
34
+
35
+ **1. Scope.** Confirm what you are profiling (repo, subdir, or one language). Default to the repo root; in a polyglot repo, produce one section per significant language. Sample representative files (entry points, core modules, a few tests), do not read everything. Skip vendored and generated code (`node_modules`, `dist`, `build`, lockfiles, migrations, anything in `.gitignore`).
36
+
37
+ **2. Read ground truth.** Config files are enforced, so they settle whole categories before you read source. Find and read whatever exists (see the [config map](#config-map) below), record each rule as **enforced**, and note the command that applies it (`npm run format`, `ruff format .`, `gofmt -w .`). Code that passes the formatter inherits these for free, so the profile says "run X" rather than re-deriving them.
38
+
39
+ **3. Measure.** Run the bundled [stats helper](#stats-helper) to get histograms the eye cannot estimate (naming casing per kind, identifier length, function length, comment density, doc-comment coverage, TODO/FIXME count, indentation, quote style, boolean-prefix share among lowercase identifiers, comment length and sentence style, person and contraction use, and error-message capitalization and punctuation). Treat its output as evidence to interpret, not as the profile. If it disagrees with the code, trust the code.
40
+
41
+ **4. Close-read for voice.** Numbers cannot capture voice. Read your sample against [What to look for](#what-to-look-for) and note especially where the author is the opposite of an [AI tell](#ai-tells), because those are the spots contributions slip. Sample each prose channel that exists: comments and docstrings, errors and validation messages, logs, test descriptions, CLI or UI text, and repository documentation. Keep the channels separate when they differ.
42
+
43
+ **5. Optional: focus on one author.** To mimic a specific person in a multi-contributor repo, isolate their files first, then sample from those and note the profile is author-scoped:
44
+ ```
45
+ git log --author="<name-or-email>" --pretty=format: --name-only | sort | uniq -c | sort -rn | head -30
46
+ ```
47
+ For heavily-shared files, spot-check `git blame` before treating them as representative.
48
+
49
+ **6. Write CODEDNA.md.** Synthesize into the target repo's `CODEDNA.md` using the [template](#codednamd-template). Hold to these standards, a profile that fails them will not change how code gets written:
50
+ - **Specific, not generic.** "Uses descriptive names" is worthless. "Functions are verb-first camelCase (`loadUser`); booleans are `is`/`has`-prefixed; collections are plural" is usable. If a line would be true of any repo, sharpen or cut it.
51
+ - **Show, do not just tell.** Pair each convention with a real two-to-four-line snippet from the codebase.
52
+ - **Note the dominant pattern and its real exceptions.** Characteristic inconsistencies are part of the fingerprint ("named exports, but components are default-exported").
53
+ - **Separate enforced from observed**, so a reader knows what is load-bearing.
54
+ - **Capture positive voice, not only prohibitions.** Record the words, rhythm, directness, and channel-specific habits that new work should preserve.
55
+ - **Apply the substitution test.** If a profile sentence could appear unchanged in another repository's profile, make it concrete or cut it.
56
+
57
+ **7. Wire it in.** A profile no agent loads changes nothing. After writing `CODEDNA.md`, run the bundled wiring helper:
58
+
59
+ ```sh
60
+ python3 "<skill-dir>/scripts/codedna_wire.py" <target-dir>
61
+ ```
62
+
63
+ Resolve `<skill-dir>` to the directory containing this `SKILL.md`. By default, the helper creates or updates `AGENTS.md` as the portable baseline and updates tool-specific files that already exist. If the user asks for all-agent wiring, run it with `--all`. It prints one line per file, marked `created`, `updated`, or `unchanged`.
64
+
65
+ If you cannot run the helper, add or replace an idempotent codedna block in the agent instruction files the repo uses. Always create or update `AGENTS.md` as the portable baseline unless the user asks otherwise. Also update tool-specific files when they already exist or when the user asks for all-agent wiring:
66
+ - `CLAUDE.md` for Claude Code.
67
+ - `GEMINI.md` for Gemini CLI.
68
+ - `.github/copilot-instructions.md` for GitHub Copilot.
69
+ - `.cursor/rules/codedna.mdc` for Cursor project rules.
70
+ - `.devin/rules/codedna.md` or `.windsurf/rules/codedna.md` for Windsurf/Cascade rules.
71
+
72
+ Use this markdown block for plain instruction files (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, and Copilot instructions):
73
+ ```
74
+ <!-- codedna:start -->
75
+ ## Code and prose style
76
+
77
+ When writing or editing code or repository prose, match the conventions in [CODEDNA.md](CODEDNA.md): naming, formatting, comment and message voice, structure, and idioms, so new contributions match the existing work. Before finishing, self-check against the "AI tells" section of that file.
78
+ <!-- codedna:end -->
79
+ ```
80
+ When creating a Cursor rule, prepend:
81
+ ```
82
+ ---
83
+ description: Apply the codedna style profile for this repository.
84
+ alwaysApply: true
85
+ ---
86
+ ```
87
+ When creating a Windsurf/Cascade rule, prepend:
88
+ ```
89
+ ---
90
+ trigger: always_on
91
+ ---
92
+ ```
93
+ Tell the user which files you added or updated and that they can delete the codedna block or rule file. Do not silently rewrite unrelated parts of any agent instruction file.
94
+
95
+ **8. Report.** Summarize the headline conventions, anything surprising, and where the codebase is inconsistent enough that "matching" means picking the locally-dominant choice per file.
96
+
97
+ ---
98
+
99
+ ## Mode: Match
100
+
101
+ 1. Load the repo's `CODEDNA.md` (run Map first if absent).
102
+ 2. Read two or three real files next to where your code will live. The profile is the general law; neighbors are the local dialect, and local wins on conflicts.
103
+ 3. Write the contribution following the profile: naming, comment density and voice, structure, error-handling posture, idioms, and any human-facing prose. Reuse existing helpers and vocabulary instead of inventing parallel ones.
104
+ 4. If the change contains prose, compare each channel against real examples from that same channel. Do not make an error message sound like the README or a test name sound like a log line unless the repository does.
105
+ 5. Before presenting, self-check against [AI tells](#ai-tells). Ask, "What still sounds unlike this repository?" Fix the answer. Run the formatter if the repo has one.
106
+
107
+ The bar: if the author scrolled past your code in review, would anything make them think "I did not write this"? Remove it.
108
+
109
+ ---
110
+
111
+ ## Mode: Check
112
+
113
+ 1. Load `CODEDNA.md`. Identify the code or repository prose under review: named file, pasted text, `git diff --staged`, or `git diff`. If the user does not specify a target and the repo has a diff, default to the diff because pre-commit review is where Check mode is most useful.
114
+ 2. Check profile freshness. If the generated date in `CODEDNA.md` predates significant style churn in recent commits, say so and recommend re-running Map before relying on fine-grained tells.
115
+ 3. Compare against the profile and [AI tells](#ai-tells), category by category. For prose, use the generic prose checks only where repository evidence is silent.
116
+ 4. Report findings grouped by category. For each: quote the snippet, name the deviation, rate it (high = clearly flags a different author; low = minor), and give a concrete rewrite in house style. End with the highest-signal giveaways and whether it would pass as the author's own work. Do not force a fixed number of findings. Do not flag correct work that already matches; a false tell is as unhelpful as a missed one.
117
+
118
+ ---
119
+
120
+ ## What to look for
121
+
122
+ For every dimension: find the dominant pattern, capture a real example, note the characteristic exceptions. Skip what does not apply.
123
+
124
+ - **Naming** (highest signal, unenforced). Casing per kind (functions, methods, types/classes, constants, variables, files, CSS classes). Word choice: terse or descriptive, abbreviations (`cfg`, `ctx`) or full words, length. Verb dialect (`get` vs `fetch` vs `load`, stay consistent with theirs). Booleans (`is`/`has`/`should` prefix). Collections (plural?). Privates (leading `_`? `#`?). Event handlers (`onClick` vs `handleClick`).
125
+ - **Comments and docs** (high signal, unenforced). Density. The *why* (intent, gotchas) or the *what* (narration). Register: terse fragments or full sentences, lowercase or capitalized, impersonal or first-person. Doc comments (JSDoc/docstrings on everything, or only public API; which format). Markers (`TODO`/`FIXME`). Banners and dividers (present, or absent so contributions do not add them).
126
+ - **Human-facing prose by channel.** For errors, validation, logs, tests, CLI or UI text, and repository docs: sentence length and rhythm; fragment vs sentence; capitalization and terminal punctuation; first, second, or impersonal voice; contractions; directness; recurring verbs; amount of context; instructions vs statements. Compare like with like.
127
+ - **Structure.** Function size. Eager extraction or inline-heavy; where helpers live. File organization and ordering. Module shape (flat or nested, barrel files, feature vs layer folders). Paradigm (OO, functional, procedural; composition vs inheritance).
128
+ - **Control flow.** Early returns or nested conditionals. Ternary tolerance. Loops vs higher-order functions. `switch` vs lookup maps. Async style (`async`/`await` vs `.then`; `Promise.all`).
129
+ - **Error handling** (strong fingerprint, common AI tell). try/catch vs error-return vs Result vs let-it-throw. How defensive (validate at boundaries only, or everywhere). Custom error types or generic throws; message tone. Logging on error.
130
+ - **Types.** Explicit return types or inferred. `interface` vs `type`. `any`/`unknown` tolerance, non-null assertions. Generics naming. Enums vs union literals. Nullability conventions.
131
+ - **Imports.** Default vs named. Ordering and grouping (often enforced, check configs first). Relative vs alias paths. Barrel re-exports.
132
+ - **Tests.** Framework. Location and naming (`*.test.ts` co-located vs `tests/`). `describe`/`it` vs flat. Case naming ("returns null when empty" vs `test_x_y`). Mocking and fixtures.
133
+ - **Idioms and vocabulary** (hardest to fake, most identifying). Reused helpers (a `cn()`, a custom assert) to reuse not reinvent. Characteristic patterns (the standard shape of a component/handler). Domain nouns and verbs, match them exactly. Accepted abbreviations. Logging style. Small tics (template literals vs concat, default params, guard-clause style).
134
+
135
+ ### Config map
136
+
137
+ Read these first; they are enforced.
138
+
139
+ | Language | Config files | Mainly settles |
140
+ | --- | --- | --- |
141
+ | All | `.editorconfig` | indent, line endings, final newline |
142
+ | JS / TS | `.prettierrc*`, `.eslintrc*`, `eslint.config.*`, `biome.json`, `tsconfig.json` | quotes, semicolons, trailing commas, width, import rules, strictness |
143
+ | Python | `pyproject.toml` (`[tool.black]`, `[tool.ruff]`, `[tool.isort]`), `setup.cfg`, `.flake8` | line length, quotes, import order, lint |
144
+ | Go | gofmt/gofumpt (implicit), `.golangci.yml` | formatting fixed by gofmt; lint |
145
+ | Rust | `rustfmt.toml`, `clippy.toml` | formatting, clippy |
146
+ | Ruby | `.rubocop.yml` | layout, cops |
147
+ | Java / Kotlin | `checkstyle.xml`, `.ktlint`, spotless | layout, naming |
148
+ | C / C++ | `.clang-format`, `.clang-tidy` | brace style, column limit |
149
+ | C# | `.editorconfig` (Roslyn), `*.ruleset` | naming, layout |
150
+ | Swift | `.swiftformat`, `.swiftlint.yml` | formatting, lint |
151
+
152
+ Also check `package.json` scripts, `Makefile`, `.pre-commit-config.yaml`, and CI files for the actual format/lint commands; those belong in the profile.
153
+
154
+ ---
155
+
156
+ ## AI tells
157
+
158
+ AI defaults to maximally explicit, maximally defensive, uniformly consistent, and eager to explain. Real authors are selectively terse, selectively defensive, characteristically inconsistent, and sparing with explanation. Match the author, not the default.
159
+
160
+ Repository evidence overrides every generic tell below. A pattern is a tell only when it conflicts with the author or when the profile is silent and the wording is generic. Preserve real quirks; do not invent inconsistency to make generated work look human.
161
+
162
+ **Quick self-check** before presenting code as the author's own:
163
+ - [ ] Comment density matches neighbors (not heavier); no comment narrates what the code plainly says.
164
+ - [ ] Names are the house length and dialect (not longer, not more "descriptive").
165
+ - [ ] No try/catch, null check, or validation the author would not write.
166
+ - [ ] No helper extracted that the author would inline (and vice versa).
167
+ - [ ] Comment voice matches (casing, punctuation, terseness, person).
168
+ - [ ] Reuses existing helpers and vocabulary; no parallel utilities.
169
+ - [ ] No section banners, decorative dividers, or emoji unless the repo uses them.
170
+ - [ ] No leftover scaffolding (example-usage blocks, debug logs, restated-prompt comments).
171
+ - [ ] Human-facing prose matches examples from the same channel.
172
+ - [ ] Every claim names a concrete behavior, actor, source, command, or measurement when one exists.
173
+ - [ ] No sentence could move unchanged to an unrelated repository without losing meaning.
174
+ - [ ] Formatter has been run if the repo has one.
175
+
176
+ **The catalog** (during Check, for each: snippet, which tell, severity, rewrite):
177
+ 1. **Over-commenting**: a comment above nearly every block. Delete those that restate the code.
178
+ 2. **Narrating the obvious**: `// increment counter`. Remove; or improve the name.
179
+ 3. **Names longer than the house norm**: `responseData`/`handleButtonClickEvent` where the author writes `res`/`onClick`. Rename to their length and dialect.
180
+ 4. **Defensive boilerplate**: try/catch and null checks the author would not write. Match the codebase's actual defensiveness.
181
+ 5. **Over-abstraction** (or under): a one-line helper, a factory/interface the repo does not warrant. Match the author's extraction threshold.
182
+ 6. **Uniform consistency**: every rule applied perfectly. Match the local dialect of the file, including its quirks.
183
+ 7. **Docstrings on everything**: boilerplate `@param`/`@returns` that restate the signature. Document what the author documents.
184
+ 8. **Explainer voice**: "Now we iterate...", first-person-plural, full sentences in a terse repo. Match their register exactly.
185
+ 9. **Section banners and dividers** unless the repo uses them. Remove.
186
+ 10. **Emoji and decorative unicode** where the codebase has none. Remove.
187
+ 11. **Restating the prompt or plan** in comments. Delete; the code is the artifact.
188
+ 12. **Leftover scaffolding**: `if __name__ == "__main__"` demos, debug `print`/`console.log`, done TODOs. Remove.
189
+ 13. **Parallel utilities and vocabulary drift**: a new `formatDate` when one exists; `fetch`/`load` used interchangeably. Reuse the helper; use the house term.
190
+ 14. **Belt-and-suspenders typing**: explicit return types everywhere in an inferring repo, redundant casts. Match the typing posture.
191
+ 15. **Verbose logging and error messages** in a repo that logs sparingly. Match the density and style of neighbors.
192
+
193
+ **Generic prose fallback** (use only when repository evidence is absent):
194
+ 1. **Puffery and promotion**: praise replaces information. State the behavior or evidence.
195
+ 2. **Vague attribution**: phrases such as "experts believe" and "reports suggest" hide the source. Name it or remove the claim.
196
+ 3. **Formulaic transitions**: superficial `-ing` clauses and "despite challenges" framing often add no causal fact. Delete them or explain the mechanism.
197
+ 4. **AI-favored vocabulary**: abstract words such as "pivotal", "intricate", "tapestry", and "landscape" often have a shorter concrete replacement. Prefer the repository's ordinary vocabulary.
198
+ 5. **Rhetorical scaffolding**: "not just X, but Y", false `from X to Y` ranges, forced list sizes, and synonym cycling impose shape without adding meaning. State the point directly and repeat the established term.
199
+ 6. **Chatbot residue**: greetings, praise for the prompt, offers to help further, and canned conclusions belong to the conversation, not the artifact. Remove them.
200
+ 7. **Filler and hedging**: shorten "in order to" to "to", delete throat-clearing, and reduce stacked qualifiers to the one uncertainty the evidence supports.
201
+ 8. **Generic conclusions**: replace predictions or mood with the next action, current limitation, measured result, or nothing.
202
+ 9. **Abstract technical metaphors**: name the actual component, operation, boundary, or constraint instead of using fashionable nouns that could describe anything.
203
+ 10. **Feeling instead of mechanism**: replace claims that something is "easy", "close at hand", or "powerful" with what the reader can do, what fails, or what changed.
204
+ 11. **Dense or passive sentences**: split ideas that require backtracking and name the actor when the actor matters.
205
+ 12. **Weak verb plus adverb**: use the measured result or a more exact verb. Do not turn this into a ban when the author's prose uses adverbs naturally.
206
+ 13. **Formulaic presentation**: repeated bold labels, inline-header lists, title-case headings, and colon-led fragments can expose a generated template. Match the repository's document structure and use labels only when they help scanning.
207
+ 14. **Punctuation drift**: straight or curly quotes, parentheses, dash punctuation, and sentence endings belong to the author's profile. Do not impose a universal punctuation preference over repository evidence.
208
+
209
+ ---
210
+
211
+ ## CODEDNA.md template
212
+
213
+ Adapt: drop sections that do not apply, split by language in a polyglot repo, never pad with generic filler. Mark **enforced** vs **observed**. Pair conventions with real snippets.
214
+
215
+ ```markdown
216
+ # CodeDNA: <repo or scope>
217
+
218
+ > Scope: <whole repo | path | language>. <If author-scoped: "Matched to <author>.">
219
+ > Generated by codedna v1.2.0 on <date>. Re-run after deliberate style changes.
220
+
221
+ ## TL;DR
222
+ The smallest useful set of high-signal rules for blending in, scannable and specific.
223
+
224
+ ## Enforced by tooling
225
+ - Format: `<command>` Lint: `<command>`
226
+ - <config file> sets: <indent, quotes, semicolons, width, import order, ...>
227
+
228
+ ## Naming
229
+ - Functions/vars/types/constants/booleans/files: <casing + habit + real example>
230
+ - Verb dialect / accepted abbreviations / exceptions.
231
+
232
+ ## Formatting (beyond enforced)
233
+ - Line length observed; blank-line habits; anything the formatter does not cover.
234
+
235
+ ## Comments and documentation
236
+ - Density; why vs what; register; doc-comment norms; markers; banners.
237
+ - Example (verbatim from the repo).
238
+
239
+ ## Human-facing prose
240
+ - Separate patterns for errors, validation, logs, tests, CLI or UI text, and repository docs when present.
241
+ - Sentence or fragment style; length and rhythm; capitalization and punctuation; person and contractions; directness and recurring vocabulary.
242
+
243
+ ## Voice cues to preserve
244
+ - Positive, channel-specific habits new work should reproduce, each backed by a real example.
245
+
246
+ ## Structure and decomposition
247
+ - Function size; extraction threshold; file organization; module shape; paradigm.
248
+
249
+ ## Control flow and error handling
250
+ - Control-flow habits; async style; error posture and defensiveness; custom errors; logging.
251
+ - Example (a real error-handling snippet).
252
+
253
+ ## Types
254
+ - Return types; interface vs type; any tolerance; generics; nullability.
255
+
256
+ ## Imports and modules
257
+ - Default vs named; ordering; relative vs alias.
258
+
259
+ ## Tests
260
+ - Framework; location/naming; structure; case naming; mocking.
261
+
262
+ ## Idioms and vocabulary
263
+ - Reused helpers; characteristic patterns; domain vocabulary; logging; small tics.
264
+
265
+ ## Known inconsistencies
266
+ - Where the codebase disagrees with itself; match the local file, not a global rule.
267
+
268
+ ## AI tells to avoid here
269
+ - The specific places this author is the opposite of the AI default.
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Stats helper
275
+
276
+ A best-effort, stdlib-only fingerprint. Run:
277
+
278
+ ```sh
279
+ python3 "<skill-dir>/scripts/codedna_stats.py" <target-dir>
280
+ ```
281
+
282
+ Resolve `<skill-dir>` to the directory containing this `SKILL.md`. If the host exposes a skill-directory environment variable, use that path. If `python3` is unavailable, try `python`; if neither runs, skip this step, build the profile from configs and close reading, and say in the report that no measurements were taken. The helper grounds the profile in real frequencies; read the sampled source as well to capture voice. Inside a Git work tree it measures only files Git would track, so `.gitignore` entries stay out; elsewhere, or when the target itself is ignored, it walks the tree. Either way it skips vendored, build, and hidden directories. It reports when a language sample is capped (the cap spreads the sample evenly across paths), when oversized or minified files are skipped, and when `lower` or `UPPER` marks a single-word name that is compatible with more than one convention. It also reports function-size distribution, identifier-length distribution, boolean-prefix share among lowercase identifiers, TODO/FIXME count, doc-comment coverage, comment length and sentence style, person and contraction use, and literal error-message capitalization and punctuation where the language heuristics support them. These are descriptive measurements, not lint violations.
283
+
284
+ ## Keeping the profile fresh
285
+
286
+ `CODEDNA.md` is a snapshot. After a deliberate style shift (new linter, framework migration, a refactor that changes conventions), re-run Map to refresh it.