Ask Claude to Detect Your Code Style and Generate an .editorconfig File
Code style debates waste time. Instead of arguing about indentation, let Claude read what you already have and lock it into an .editorconfig that every editor respects automatically.
"Read the codebase and generate an .editorconfig that matches our existing code style"
Claude samples files across your project — PHP, JavaScript, CSS, YAML, Markdown — detects the patterns in each, and generates rules that match reality:
# What Claude generates from your actual code:
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{js,ts,jsx,tsx}]
indent_size = 2
[*.{yml,yaml}]
indent_size = 2
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab
This works for any project state:
# New project — set up style from scratch
"Generate an .editorconfig using standard conventions for a Laravel project"
# Existing project — match what's already there
"Detect the code style in this project and generate an .editorconfig that preserves it"
# Mixed project — handle each language differently
"Generate an .editorconfig with language-specific rules for our PHP backend
and React frontend"
# Fix inconsistencies
"Some files use tabs and some use spaces. Generate an .editorconfig
that standardizes on the majority style, then reformat the outliers"
Claude can also fix existing inconsistencies after generating the config:
"Now reformat any files that don't match the .editorconfig rules"
The .editorconfig is supported by nearly every editor and IDE out of the box — VS Code, PhpStorm, Sublime, Vim, Emacs — no plugins needed for most. Once committed, every contributor's editor follows the same rules.
The best code style is the one you never discuss — an .editorconfig enforces it silently in every editor your team uses.
via Claude Code
Log in to leave a comment.
When Claude writes error messages, button labels, validation text, or onboarding flows, it defaults to generic developer-speak. Add a "Users" section to your CLAUDE.md describing who your actual users are — their technical level, industry jargon, and what they care about — so Claude writes copy that makes sense to THEM, not to developers.
Use the --agent flag with custom markdown files in .claude/agents/ to launch purpose-built Claude sessions with restricted tools and scoped system prompts.
Every project has traps — the billing module that silently fails if you forget to queue the job, the legacy table with column names that don't match the model, the config value that must be set before tests run. Document these gotchas in your CLAUDE.md so Claude avoids the same mistakes your team spent days debugging.