Phoenix

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Phoenix framework development guidelines covering LiveView, Ecto, real-time features, and best practices for building scalable web applications with Elixir.

AI 產生的概覽

用於建置 Elixir Phoenix 網頁應用程式的指南,涵蓋 LiveView、Ecto 與 Tailwind CSS。

功能
此技能提供開發 Elixir 與 Phoenix 網頁應用程式的程式碼撰寫指南。內容涵蓋程式碼風格、命名慣例、Ecto 用法、錯誤處理、LiveView 與 Tailwind 介面、效能最佳化、架構模式、ExUnit 測試以及安全實務。它產出的是指引建議,而非檔案或指令碼。
適用情境
在撰寫、審查或組織 Elixir 與 Phoenix 應用程式程式碼時使用。適合涉及 LiveView 介面、Ecto 資料庫操作、context、GenServer 或 ExUnit 測試的工作。
執行需求
不包含指令碼或資源,僅為說明性指引。若要遵循這些指引,需要 Elixir 與 Phoenix 專案、PostgreSQL、Tailwind CSS,以及 ExUnit、ExMachina 等測試工具。

Phoenix Framework Development

You are an expert in Elixir, Phoenix, PostgreSQL, LiveView, and Tailwind CSS.

Code Style and Structure

  • Write concise, idiomatic Elixir code with accurate examples
  • Follow Phoenix conventions and established best practices
  • Leverage functional programming patterns and immutability principles
  • Favor higher-order functions and recursion over imperative loops
  • Use meaningful variable and function names (e.g., user_signed_in?, calculate_total)
  • Organize files per Phoenix conventions: controllers, contexts, views, schemas

Naming Standards

  • Use snake_case for files, functions, and variables
  • Use PascalCase for module names
  • Adhere to Phoenix naming conventions for contexts, schemas, and controllers

Elixir and Phoenix Implementation

  • Utilize pattern matching and guards effectively
  • Leverage Phoenix's built-in functions and macros
  • Apply Ecto proficiently for database operations

Syntax and Formatting

  • Follow the Elixir Style Guide
  • Chain functions with the pipe operator |>
  • Use single quotes for charlists, double quotes for strings

Error Handling

  • Embrace the "let it crash" philosophy with supervisor trees
  • Log errors properly and provide user-friendly messaging
  • Validate data through Ecto changesets
  • Display appropriate flash messages for controller errors

UI and Styling

  • Use LiveView for real-time, dynamic interactions
  • Implement responsive design with Tailwind CSS
  • Employ view helpers to maintain DRY templates

Performance Optimization

  • Index databases effectively
  • Cache strategically (ETS, Redis)
  • Prevent N+1 queries using preload, joins, or select
  • Optimize database queries for efficient data retrieval

Architecture Patterns

  • Follow RESTful routing conventions
  • Organize functionality within contexts
  • Use GenServers for stateful processes and background work
  • Deploy Tasks for concurrent, isolated operations

Testing

  • Write comprehensive ExUnit tests
  • Practice TDD (Test-Driven Development)
  • Use ExMachina for test data generation

Security

  • Implement authentication and authorization (Guardian, Pow)
  • Validate strong parameters in controllers
  • Defend against XSS, CSRF, and SQL injection vulnerabilities

來源與署名

來源:mindrally/skills位於phoenix提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架