| name | learn-code-style |
| description | Learn and maintain language-specific coding style preferences from user-authored files, functions, commit ranges, and external style guides; apply those preferences during later feature, bugfix, and refactor work in matching languages. |
Learn Code Style
Workflow
- Determine target language(s) from the user request and evidence source.
- Ingest style evidence from one or more sources:
- user-authored file/function samples
- commit history ranges or tags
- explicit style guides (local or internet)
- Extract concrete, language-scoped patterns and anti-patterns.
- Update the persistent style ledger in
references/style-ledger.md.
- On future authoring tasks, load only the matching language section from the ledger and apply it.
Source-Specific Ingestion
File or function sample
- Read the exact file/function and nearby context.
- Extract recurring signals:
- naming style
- control-flow shape
- error handling style
- comments/docstring density and tone
- test style and validation habits
- preferred library/runtime idioms
- Record only repeated patterns, not one-off anomalies.
Commit-range sample
- Inspect a bounded range (for example
tag..HEAD, A^..B).
- Sample representative diffs across the range, not just commit subjects.
- Separate style observations by language.
- Record confidence and any uncertainty in the ledger.
Internet style guides
- Use primary sources when possible (official language/project docs, well-known style guides).
- Record guide name, URL, and extraction date.
- Convert guidance into actionable rules for authoring.
- Prefer user-authored project style over generic guide defaults when conflicts occur, unless user says otherwise.
Preference Precedence
Apply style preferences in this order:
- Task-specific user instruction in current conversation.
- Language-specific patterns learned from the user's own codebase/history.
- User-approved external style guides for that language.
- Default language conventions.
Authoring-Time Behavior
When asked to implement, fix, or refactor:
- Identify implementation language(s).
- Load matching language style section(s) from
references/style-ledger.md.
- Apply preferred patterns directly in code edits.
- Before writing code, call out risks from style choices that may affect behavior, performance, security, readability, or maintenance.
- If a preferred style conflicts with correctness/safety constraints, surface the conflict and propose the smallest safe adjustment.
Side-Effect Risk Callouts (Required)
Before initiating substantial code authoring in a language with style preferences, explicitly note likely side effects such as:
- deeper chaining reducing debuggability
- terse idioms reducing readability for mixed-skill teams
- heavy abstraction increasing indirection and test burden
- strict minimalism reducing guardrails around unsafe inputs
- strict verbosity increasing churn and review noise
Keep these callouts concise and specific to the task scope.
Language Separation
Never merge styles across languages by default.
Maintain separate sections for each language and ecosystem (for example Bash, Python, Go, TypeScript).
When tasks span languages, apply each language's profile only to its own files.
Ledger Maintenance
Use references/style-ledger.md as the persistent source of truth.
For each language entry, keep:
- preferred patterns
- discouraged patterns
- examples or evidence references
- source provenance (file/function/commit-range/style-guide URL)
- confidence level and last-updated date
Update instead of duplicating entries. Keep entries concise and operational.
Quick Commands
Use scripts/style_signals.sh to collect basic style signals from a language-specific path.
Use it as a helper, not as the only source of truth.
Output Contract
When the user asks to "learn my style":
- Summarize extracted style by language.
- State what was written/updated in the ledger.
- Note any unresolved ambiguity.
When the user asks to author code later:
- State which language profile was applied.
- State key style choices used.
- Include side-effect risk callouts before implementation.