GitHub - dahan8473/snake-and-commits: Turn your GitHub contribution graph into a real game of Snake โ animated SVG, zero dependencies, drop-in Action. ยท GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
dahan8473
snake-and-commits
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>9 Commits<br>9 Commits
.github/workflows
.github/workflows
assets
assets
.gitignore
.gitignore
LICENSE
LICENSE
README.md
README.md
action.yml
action.yml
generate.py
generate.py
View all files
Repository files navigation
snake-and-commits
Your GitHub contribution graph, but it's a real game of Snake.
The snake plays an actual, winnable game. It hunts every commit cell with real<br>pathfinding, never crosses its own body, grows one segment per cell it eats,<br>fades from a bright head to a dim tail, and counts the commits it swallows. Pure<br>animated SVG (CSS, no JavaScript), so it renders anywhere GitHub shows an image.
๐ Real Snake AI : BFS pathfinding, self-collision avoidance, tail-chasing when boxed in
๐ Eats your commits : each contribution cell is food, with a live counter
๐ Grows as it eats : starts at 3 segments, gains one per cell, head-to-tail gradient
๐จ Themeable : green (default), blue, amber, matrix
๐ชถ Zero dependencies : one standard-library Python file
โฟ Respects prefers-reduced-motion : falls back to a static graph
Quickstart
Add one workflow to your profile repo (the repo named after your username).<br>Create .github/workflows/snake.yml:
name: snake<br>on:<br>schedule:<br>- cron: "0 */12 * * *" # twice a day<br>workflow_dispatch:<br>permissions:<br>contents: write<br>jobs:<br>build:<br>runs-on: ubuntu-latest<br>steps:<br>- uses: dahan8473/snake-and-commits@v1<br>with:<br>github_user: ${{ github.repository_owner }}<br>output: dist/snake.svg<br>theme: green<br>- uses: crazy-max/ghaction-github-pages@v4<br>with:<br>target_branch: output<br>build_dir: dist<br>env:<br>GITHUB_TOKEN: ${{ github.token }}
Run it once from the Actions tab, then add this to your README.md:

It regenerates on schedule from your live contribution data.
Light and dark
Generate two themes and switch with :
">picture><br>source media="(prefers-color-scheme: dark)" srcset=".../output/snake-dark.svg"><br>source media="(prefers-color-scheme: light)" srcset=".../output/snake-light.svg"><br>img src=".../output/snake-dark.svg" alt="contribution snake"><br>picture>
Options
input<br>default<br>description
github_user<br>required<br>whose graph to render (usually ${{ github.repository_owner }})
output<br>dist/snake.svg<br>output path
theme<br>green<br>green, blue, amber, matrix
frame<br>false<br>draw a rounded window frame around the graph
counter<br>true<br>show the commits eaten: n/total counter
Themes
theme<br>look
๐ฉ green<br>native GitHub
๐ฆ blue<br>phosphor terminal
๐ง amber<br>old CRT
โฌ matrix<br>bright-on-black
Run locally
GH_TOKEN=$(gh auth token) python3 generate.py --user YOUR_NAME --output snake.svg --theme green
One file, standard library only. Any token that can read public contribution<br>data works.
How it works
Pull a year of contribution levels from the GitHub GraphQL API.
Solve the board like a Snake game. From a corner, BFS to the nearest commit<br>cell (sparsest first), always avoiding the body. If the best target is walled<br>off, chase the tail until space opens. The route is collision-free, and the<br>max length is auto-tuned to the largest snake that still clears the board.
Render it as a cell-state animation. Each grid square animates its own fill:<br>bright when the head enters, fading down the body, back to background as the<br>tail passes. Nothing moves, so segments can never overlap.
Credits
Built by David Liu. Inspired by the<br>contribution-graph art tradition (Platane/snk<br>and friends), rebuilt from scratch as an actual game of Snake. MIT licensed.
pls drop a star!
About
Turn your GitHub contribution graph into a real game of Snake โ animated SVG, zero dependencies, drop-in...