elixir
यह क्या करती है
यह गाइड Elixir प्रोग्रामिंग भाषा में ज़्यादा कुशल और साफ़ कोड लिखना सिखाती है। यह कोड को व्यवस्थित करने, errors को handle करने और भाषा की सुविधाओं का इस्तेमाल करने के बेहतर तरीके दिखाती है।
कब इस्तेमाल करें
- ✓जब आप Elixir सीख रहे हों और अच्छी quality का कोड लिखना चाहते हों।
- ✓जब आप Elixir कोड को ज़्यादा पढ़ने लायक बनाने के लिए उसकी समीक्षा कर रहे हों।
- ✓जब Elixir में idiomatic तरीके से कोड लिखने में मुश्किल आ रही हो।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/super-code/elixir/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“Elixir में यह जाँचने के लिए कि कोई number even है या नहीं, मैं फ़ंक्शन को ज़्यादा कुशल तरीके से कैसे लिख सकता हूँ?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
गाइड आम तरीकों की तुलना code examples से करती है, और दिखाती है कि 'pattern matching' और 'pipe' operator जैसी सुविधाओं से logic को सरल और errors को कम कैसे किया जाए।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Elixir / Erlang: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for elixir.
Table of Contents
- Pattern Matching & Guards
- Pipe Operator & Transforms
- Processes & OTP
- Error Handling
- Collections & Enum
- Structs & Protocols
- Anti-patterns specific to Elixir/Erlang
1. Pattern Matching & Guards {#patterns}
# ❌ Extracting with Map.get then checking
value = Map.get(map, :key)
if value != nil do
process(value)
end
# ✅ — pattern match directly
case map do
%{key: value} -> process(value)
_ -> :noop
end
# or with if:
if value = map[:key], do: process(value)
# ❌ Nested case for multiple conditions
case fetch_user(id) do
{:ok, user} ->
case validate(user) do
{:ok, valid_user} -> save(valid_user)
{:error, reason} -> {:error, reason}
end
{:error, reason} -> {:error, reason}
end
# ✅ — with clause
with {:ok, user} <- fetch_user(id),
{:ok, valid_user} <- validate(user) do
save(valid_user)
end
# ❌ if/else for known shapes
def area(shape) do
if shape.type == :circle do
:math.pi() * shape.radius * shape.radius
else
shape.width * shape.height
end
end
# ✅ — multi-clause function with pattern match
def area(%{type: :circle, radius: r}), do: :math.pi() * r * r
def area(%{type: :rect, width: w, height: h}), do: w * h
# ❌ Checking type at runtime
def process(x) do
if is_integer(x) and x > 0 do
x * 2
end
end
# ✅ — guard clause
def process(x) when is_integer(x) and x > 0, do: x * 2
def process(_), do: {:error, :invalid_input}
2. Pipe Operator & Transforms {#pipes}
# ❌ Nested function calls
String.trim(String.downcase(String.replace(input, ~r/\s+/, " ")))
# ✅
input
|> String.replace(~r/\s+/, " ")
|> String.downcase()
|> String.trim()
# ❌ Pipe into anonymous function awkwardly
data
|> (fn x -> x * 2 end).()
# ✅ — use then/1 or named function
data
|> then(&(&1 * 2))
# or better: extract a named function
data |> double()
# ❌ Single-step pipe (no gain in readability)
result = list |> Enum.count()
# ✅ — direct call for single operation
result = Enum.count(list)
Pipe when 2+ transforms. Direct call for single operation. First arg flows through pipe.
3. Processes & OTP {#otp}
# ❌ Raw spawn for stateful process
pid = spawn(fn -> loop(%{count: 0}) end)
send(pid, {:increment})
# ✅ — GenServer for stateful processes
defmodule Counter do
use GenServer
def start_link(init \\ 0), do: GenServer.start_link(__MODULE__, init)
def increment(pid), do: GenServer.call(pid, :increment)
@impl true
def init(count), do: {:ok, count}
@impl true
def handle_call(:increment, _from, count), do: {:reply, count + 1, count + 1}
end
# ❌ Spawning without linking (orphan process on crash)
spawn(fn -> do_work() end)
# ✅ — Task for fire-and-forget with supervision
Task.start(fn -> do_work() end)
# or for awaitable result:
task = Task.async(fn -> do_work() end)
result = Task.await(task)
# ❌ Manual process registry
Process.register(self(), :my_worker)
# ✅ — use Registry or named GenServer
{:ok, _} = Registry.start_link(keys: :unique, name: MyRegistry)
GenServer.start_link(Worker, arg, name: {:via, Registry, {MyRegistry, :my_worker}})
# ❌ try/catch in GenServer (breaks supervision)
def handle_call(:work, _from, state) do
try do
result = risky_operation()
{:reply, result, state}
catch
_ -> {:reply, :error, state}
end
end
# ✅ — let it crash; supervisor restarts
def handle_call(:work, _from, state) do
result = risky_operation()
{:reply, result, state}
end
"Let it crash" — supervisors handle recovery. Don't defensively catch inside GenServers.
4. Error Handling {#errors}
# ❌ Raising for expected failures
def find_user(id) do
case Repo.get(User, id) do
nil -> raise "User not found"
user -> user
end
end
# ✅ — tagged tuples for expected outcomes
def find_user(id) do
case Repo.get(User, id) do
nil -> {:error, :not_found}
user -> {:ok, user}
end
end
# ❌ Ignoring error tuple
{:ok, result} = might_fail() # crashes on {:error, _}
# ✅ — handle both cases
case might_fail() do
{:ok, result} -> process(result)
…
अक्सर पूछे जाने वाले सवाल
'pattern matching' क्या है?
यह code के structures में से data को सुंदर तरीके से जाँचने और निकालने का तरीका है। जैसे किसी map में कोई key है या नहीं, यह जाँचना और उसकी value एक साथ पाना।
'pipe' operator (`|>`) क्या है?
यह कई function calls को पढ़ने में आसान तरीके से जोड़ने देता है। एक function का result अगले function को argument के रूप में जाता है, और यह ऊपर से नीचे की ओर चलता है।
'Let it crash' का मतलब क्या है?
यह Elixir की एक सोच है, जिसमें हर संभावित error को पकड़ने की कोशिश करने के बजाय program को नियंत्रित तरीके से fail होने दिया जाता है, और एक supervision system ज़रूरी हिस्सों को अपने आप restart कर देता है।
जानकारी
लेखक का मूल विवरण
Language-specific super-code guidelines for elixir.
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #5891
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।