Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Wordle Battle is a real-time competitive Wordle game built with Phoenix LiveView. Players compete simultaneously to guess the most 5-letter words within a timed session, with scoring based on speed and accuracy.
mix setup - Install dependencies and build assets (first-time setup)mix phx.server - Start Phoenix server (visit http://localhost:4000)iex -S mix phx.server - Start Phoenix server in interactive Elixir shellmix precommit - Run full pre-commit checks (compile with warnings as errors, format, test)mix test - Run all testsmix test test/path/to/test.exs - Run specific test filemix test --failed - Run only previously failed testsmix assets.build - Build Tailwind + esbuild assetsmix assets.deploy - Build and minify assets for productionThe game uses a GenServer-based architecture with Phoenix LiveView for real-time UI:
WordleServer (GenServer): Each game session runs as a supervised GenServer process
WordleLive (LiveView): Real-time UI for players
Dynamic Supervision: Sessions registered via Registry for efficient lookup
Registry.lookup/2 for finding session processesDynamicSupervisor for fault-tolerant session managementPubSub Broadcasting: Real-time updates to all session participants
application.exWordleBattle.Dictionary - provides answer_words/0, valid_guesses/0, random_word/1used_words list prevents word repetition within a sessionpriv/dictionary/answer_words.txt and priv/dictionary/valid_guesses.txt:lobby -> :playing # All players ready → start_game :playing -> :game_over # Timer expires → calculate winners :game_over -> :lobby # start_new_game → reset with preserved players
Two-pass algorithm to handle duplicate letters correctly:
<Layouts.app> wrapper in all LiveView templates (already aliased in wordle_battle_web.ex)to_form/2 in LiveView, access via @form[:field] in templates<.link navigate={}> and <.link patch={}>, not deprecated live_redirect/live_patch<.icon name="hero-x-mark" /> component from core_components.exUse streams for player lists, word history, and leaderboards to prevent memory issues:
# In LiveView stream(socket, :players, [new_player]) # append stream(socket, :players, players, reset: true) # replace all # In template (must set phx-update="stream" on parent) <div id="players" phx-update="stream"> <div :for={{id, player} <- @streams.players} id={id}> {player.nickname} </div> </div>
<.form for={@form} id="guess-form">)assert has_element?(view, "#guess-form")render_submit/2 and render_change/2 for form testingLazyHTML for debugging complex selectorsDictionary.valid_guesses/0 MapSet (O(1) lookup)Dictionary.answer_words/0 list (~2,300 common words)Use
:timer.send_interval/2 in GenServer for countdown:
:game_over when time_remaining reaches 0/sounds/timer_end.mp3) on expirationuser_id from localStorage on mountWordleServer.restore_session(session_id, user_id)Enum.at(list, index) instead of list[index]else if: Use cond for multiple conditionalsstruct.field or Ecto.Changeset.get_field/2String.to_atom/1 on user input (memory leak){@value} not <%= @value %>{@value} for values, <%= for/if/cond %> for blocksclass={["base", @flag && "conditional"]} (must use [...])else if: Use <%= cond do %> with clauses<%!-- comment --%> not <!-- -->Enum.filter/2 on streams.hidden.only:blockstream(socket, :items, items, reset: true)lib/wordle_battle/dictionary.ex - Word loading and validationlib/wordle_battle/wordle_server.ex - Game state GenServerlib/wordle_battle_web/live/wordle_live.ex - Main game LiveViewlib/wordle_battle_web/live/lobby_live.ex - Session creation/joiningpriv/dictionary/answer_words.txt - ~2,300 answer wordspriv/dictionary/valid_guesses.txt - ~12,000 valid wordslib/wordle_battle/application.ex - Supervision tree, preload dictionaries herelib/wordle_battle_web/router.ex - Add LiveView routes (live "/:session_id", WordleLive)lib/wordle_battle_web/components/core_components.ex - Reusable UI componentsassets/js/app.js - Client-side hooks for localStorage, keyboard input<.icon> componentmix precommit before committing - this runs:
See
WORDLE_BATTLE_SPECS.md for complete feature specifications including: