| name | naming-conventions |
| description | Comprehensive naming conventions by programming language. Auto-detects language and provides correct naming guidelines. |
Naming Conventions by Language
IMPORTANT: Naming conventions vary by language. This skill provides the correct conventions for each language.
Rule: Use the conventions of the LANGUAGE you're writing, not Java/JavaScript defaults.
🔍 Auto-Detección
Detecta el lenguaje del proyecto:
├── .py → Python (PEP 8)
├── .java → Java (Oracle)
├── .cs → C# (.NET)
├── .go → Go (Go Code Review)
├── .rs → Rust (Rust API)
├── .rb → Ruby
├── .js/.ts → JavaScript/TypeScript
├── .php → PHP (PSR)
├── .swift → Swift
├── .kt → Kotlin
└── .cpp/.c → C/C++
📋 Tabla de Convenciones
| Lenguaje | Métodos/Funciones | Variables | Constantes | Clases/Tipos | Archivos |
|---|
| Python | snake_case | snake_case | UPPER_SNAKE_CASE | PascalCase | snake_case |
| C# | PascalCase | PascalCase | PascalCase | PascalCase | PascalCase |
| Go | PascalCase (exp), snake_case (priv) | snake_case | UPPER_SNAKE_CASE | PascalCase | snake_case |
| Rust | snake_case | snake_case | UPPER_SNAKE_CASE | PascalCase | snake_case |
| JavaScript | camelCase | camelCase | UPPER_SNAKE_CASE | PascalCase | kebab-case |
| TypeScript | camelCase | camelCase | UPPER_SNAKE_CASE | PascalCase | kebab-case |
| Ruby | snake_case | snake_case | UPPER_SNAKE_CASE | PascalCase | snake_case |
| PHP | camelCase/snake | camelCase | UPPER_SNAKE_CASE | PascalCase | kebab/snake |
| Swift | camelCase | camelCase | UPPER_SNAKE_CASE | PascalCase | snake_case |
| Kotlin | camelCase | camelCase | UPPER_SNAKE_CASE | PascalCase | kebab-case |
| Java | camelCase | camelCase | UPPER_SNAKE_CASE | PascalCase | kebab-case |
| Scala | camelCase | camelCase | UPPER_SNAKE_CASE | PascalCase | kebab-case |
🐍 Python (PEP 8)
def get_user_by_id(user_id: int) -> Optional[User]:
"""Get user by ID."""
pass
user_list = []
max_connections = 100
MAX_CONNECTIONS = 100
DEFAULT_TIMEOUT = 30
class UserService:
pass
class UserStatus:
ACTIVE = "active"
INACTIVE = "inactive"
user_service.py
auth_controller.py
Tools para Python
| Herramienta | Propósito | Comando |
|---|
| Black | Auto-formateo | black . |
| isort | Import sorting | isort . |
| flake8 | Linting PEP 8 | flake8 . |
| pylint | Code analysis | pylint . |
| mypy | Type checking | mypy . |
⚡ C# (.NET Microsoft Conventions)
public User GetUserById(int userId)
{
return _repository.GetById(userId);
}
public int MaxConnections { get; set; }
public string UserName { get; set; }
var userList = new List<User>();
var maxConnections = 100;
public const int MaxConnections = 100;
public const string DefaultTimeout = "30s";
public class UserService
{
public class UserResponse
{
}
}
UserService.cs
AuthController.cs
Links oficiales
🔷 Go (Go Code Review Comments)
func GetUserByID(userID int) (*User, error) {
UserList := []User{}
return &User{ID: userID}, nil
}
func get_user_by_id(user_id int) (*User, error) {
user_list := []User{}
return nil, errors.New("not found")
}
userList := []User{}
maxConnections := 100
const MAX_CONNECTIONS = 100
type UserService struct{}
type User struct{}
user_service.go
auth_controller.go
Links oficiales
🦀 Rust (Rust API Guidelines)
fn get_user_by_id(user_id: i32) -> Option<User> {
let max_connections = 100;
let user_list: Vec<User> = vec![];
user_id
}
let user_list: Vec<User> = vec![];
const MAX_CONNECTIONS: i32 = 100;
struct UserService;
enum UserStatus {
Active,
Inactive,
}
user_service.rs
auth_controller.rs
mod user_service;
mod auth_controller {
pub mod handlers;
}
Links oficiales
📦 JavaScript (Airbnb Style)
function getUserById(userId) {
const maxConnections = 100;
const userList = [];
return userId;
}
let userList = [];
const maxConnections = 100;
const MAX_CONNECTIONS = 100;
const DEFAULT_TIMEOUT = '30s';
const getUserById = (userId) => {
return userId;
};
class UserService {
constructor() {
this.maxConnections = 100;
}
getUserById(userId) {
return userId;
}
}
user-service.js
UserService.js (for components)
auth-controller.js
Links oficiales
🔵 TypeScript
function getUserById(userId: number): User | undefined {
const maxConnections: number = 100;
const userList: User[] = [];
return userId;
}
let userList: User[] = [];
const maxConnections: number = 100;
const MAX_CONNECTIONS = 100;
interface User {
id: number;
name: string;
}
type UserResponse = {
data: User;
error: null;
};
class UserService {
getUserById(userId: number): User | undefined {
return userId;
}
}
enum UserStatus {
= ,
= ,
}
user-service.
auth-controller.
types.
💎 Ruby
def get_user_by_id(user_id)
max_connections = 100
user_list = []
user_id
end
user_list = []
max_connections = 100
MAX_CONNECTIONS = 100
DEFAULT_TIMEOUT = 30
class UserService
def get_user_by_id(user_id)
end
end
module Api
module V1
class UsersController
end
end
end
user_service.rb
auth_controller.rb
Links oficiales
🐘 PHP (PSR Standards)
public function getUserById(int $userId): ?User
{
$maxConnections = 100;
$this->maxRetryCount = 3;
return $userId;
}
private $userList = [];
protected $maxConnections = 100;
const MAX_CONNECTIONS = 100;
const DEFAULT_TIMEOUT = 30;
class UserService
{
public function getUserById(int $userId): ?User
{
return $userId;
}
}
interface UserRepositoryInterface
{
public function findById(int $id): ?User;
}
{
}
user-service.php
auth-controller.php
Links oficiales
🏃 Swift (Apple Swift API Design)
func getUserById(_ userId: Int) -> User? {
let maxConnections = 100
let maxRetryCount = 3
var userList: [User] = []
return userId
}
var userList: [User] = []
let maxConnections = 100
static let maxRetryCount = 3
class UserService {
struct User {
let id: Int
}
}
enum UserStatus {
case active
case inactive
}
protocol UserRepositoryProtocol {
func findById(_ id: Int) -> User?
}
user_service.swift
auth_controller.swift
Links oficiales
☕ Kotlin (Kotlin Coding Conventions)
fun getUserById(userId: Int): User? {
val maxConnections = 100
val userList: List<User> = emptyList()
return userId
}
val userList: List<User> = emptyList()
var maxConnections = 100
companion object {
const val MAX_CONNECTIONS = 100
const val DEFAULT_TIMEOUT = 30
}
class UserService {
class User(
val id: Int,
val name: String
) {
fun getUserById(userId: Int): User? = null
}
}
object UserConfig {
const val MAX_CONNECTIONS = 100
}
user-service.kt
auth-controller.kt
Links oficiales
☕ Java (Oracle Code Conventions)
public User getUserById(int userId) {
int maxConnections = 100;
List<User> userList = new ArrayList<>();
return null;
}
private int maxConnections = 100;
private List<User> userList = new ArrayList<>();
public static final int MAX_CONNECTIONS = 100;
private static final int DEFAULT_TIMEOUT = 30;
public class UserService {
private static final int MAX_CONNECTIONS = 100;
public User getUserById(int userId) {
return null;
}
}
{
User ;
}
{
ACTIVE,
INACTIVE
}
user-service.java
UserService.java
AuthController.java
Links oficiales
🎯 Decision Tree: ¿Cuál convención usar?
START: ¿Qué estás nombrando?
│
├── Función/Método
│ ├── Python → snake_case
│ ├── C# → PascalCase
│ ├── Go → PascalCase (exported) / snake_case (private)
│ ├── Rust → snake_case
│ ├── JavaScript → camelCase
│ └── Java → camelCase
│
├── Variable
│ ├── Python → snake_case
│ ├── C# → PascalCase
│ ├── Go → snake_case
│ ├── Rust → snake_case
│ ├── JavaScript → camelCase
│ └── Java → camelCase
│
├── Constante
│ ├── Python → UPPER_SNAKE_CASE
│ ├── C# → PascalCase
│ ├── Go → UPPER_SNAKE_CASE
│ ├── Rust → UPPER_SNAKE_CASE
│ ├── JavaScript → UPPER_SNAKE_CASE
│ └── Java → UPPER_SNAKE_CASE
│
├── Clase/Tipo
│ ├── Todos → PascalCase
│
└── Archivo
├── Python → snake_case
├── C# → PascalCase
├── Go → snake_case
├── Rust → snake_case
├── JavaScript → kebab-case o PascalCase
└── Java → kebab-case o PascalCase
❌ Errores comunes a evitar
| Lenguaje | ERROR | CORRECTO |
|---|
| Python | def getUserById() | def get_user_by_id() |
| C# | var user_list = [] | var userList = [] |
| Go | func get_user_by_id() (exported) | func GetUserByID() |
| Rust | fn GetUserById() | fn get_user_by_id() |
| JavaScript | const User_List = [] | const userList = [] |
| Ruby | def GetUserById | def get_user_by_id |
🔧 Linters por Lenguaje
| Lenguaje | Linter | Auto-fix |
|---|
| Python | Ruff, flake8, pylint | ✅ |
| C# | StyleCop, ReSharper | ⚠️ |
| Go | golangci-lint, go fmt | ✅ |
| Rust | cargo clippy, cargo fmt | ✅ |
| JavaScript | ESLint, Prettier | ✅ |
| TypeScript | ESLint, Prettier | ✅ |
| Ruby | RuboCop | ✅ |
| PHP | PHP-CS-Fixer, PHPStan | ✅ |
| Swift | SwiftLint | ⚠️ |
| Kotlin | ktlint, detekt | ✅ |
Remember: There is NO universal coding standard.
Follow the conventions of the LANGUAGE you're using.
When in doubt, run the language's linter - it will tell you the correct convention.