# Getting started with Elf

Elf helps you fetch Advent of Code inputs, work through puzzles in Positron, submit answers, and check your progress from Python or the terminal.


# Install and connect

Elf requires Python 3.11 or later. From your puzzle project, install it as a project dependency. If you are starting with an empty folder, run `uv init` there first.

``` bash
uv add elf
uv run elf --help
```

The examples on this page use `uv run` to select the project environment. If you install with `python -m pip install elf` in an active environment or use `uv tool install elf` for CLI-only use, run `elf` directly.

Sign in to Advent of Code and copy the `session` cookie for `adventofcode.com` from your browser's storage inspector. Set it in the environment used by Elf. Set a contact email so Advent of Code can identify automated requests.

``` bash
export AOC_SESSION="your-session-cookie"
export AOC_USER_AGENT="you@example.com"
uv run elf doctor
```

In PowerShell, use `$env:AOC_SESSION = "your-session-cookie"` and `$env:AOC_USER_AGENT = "you@example.com"`. Launch Positron from a configured environment or set the variables in the environment used by its Python session. Keep the cookie out of scripts and version control. `elf doctor` checks local configuration without contacting Advent of Code.


# Solve a puzzle in Positron

``` bash
uv run elf new 2025 1
```

This creates `2025/day01.py`. Use `--output path/to/day01.py` for a custom location. Elf refuses to overwrite an existing file.

1.  Open your puzzle folder in [Positron](https://positron.posit.co/download.html) and select the Python interpreter where you installed Elf. With uv, this is the project's `.venv` interpreter. Open the generated file. In **Setup**, choose `PART = 1` or `PART = 2`. To work offline with an example, paste it into `sample` in **Load Input** and set `USE_SAMPLE = True`.
2.  Run **Setup** through the selected part. Edit `data = lines` in **Parse Input** as needed, then replace the answer placeholder in the selected part. Inspect `raw`, `lines`, `data`, and your intermediate variables in the Variables pane.
3.  For a real answer, set `USE_SAMPLE = False` and rerun **Setup** through the selected part. Inspect the result, set `SUBMIT = True` in the console, and run **Submit**. The flag resets after each attempt and when you reload, parse, or recompute.

Rerun from **Setup** after changing the puzzle, input mode, or Advent of Code account. Loading or parsing input clears both answers. Submission requires a computed answer for the selected part and real input for the current year and day. If the session cookie changes after input is loaded, rerun from **Load Input** through the selected part before submitting.

You can also run `uv run python 2025/day01.py` in the configured environment. It prints the selected answer once implemented. Submission is off by default.


# Use Elf from Python

``` python
from elf import get_puzzle_input, get_user_status

lines = get_puzzle_input(2025, 1).splitlines()
status = get_user_status(2025)
print(status.total_stars)
```

The same session configuration applies in Python. See **Reference** for [submit_puzzle_answer](reference/submit_puzzle_answer.html#elf.submit_puzzle_answer), [get_private_leaderboard](reference/get_private_leaderboard.html#elf.get_private_leaderboard), and the available result models and output formats.

See [Command-line workflows](./user-guide/command-line.html) for common commands, output formats, and cache behavior.


### Links

[View on PyPI![](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0eWxlPSJ2ZXJ0aWNhbC1hbGlnbjogLTAuMDVlbTsgbWFyZ2luLWxlZnQ6IDBlbTsgbWFyZ2luLXRvcDogMC4xZW07IiB2aWV3Ym94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik03IDdoMTB2MTAiIC8+PHBhdGggZD0iTTcgMTcgMTcgNyIgLz48L3N2Zz4=)](https://pypi.org/project/elf/)\
[Browse source code![](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0eWxlPSJ2ZXJ0aWNhbC1hbGlnbjogLTAuMDVlbTsgbWFyZ2luLWxlZnQ6IDBlbTsgbWFyZ2luLXRvcDogMC4xZW07IiB2aWV3Ym94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik03IDdoMTB2MTAiIC8+PHBhdGggZD0iTTcgMTcgMTcgNyIgLz48L3N2Zz4=)](https://github.com/typeerror/elf)\
[Issue-Tracker![](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0eWxlPSJ2ZXJ0aWNhbC1hbGlnbjogLTAuMDVlbTsgbWFyZ2luLWxlZnQ6IDBlbTsgbWFyZ2luLXRvcDogMC4xZW07IiB2aWV3Ym94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik03IDdoMTB2MTAiIC8+PHBhdGggZD0iTTcgMTcgMTcgNyIgLz48L3N2Zz4=)](https://github.com/typeerror/elf/issues)\
[Changelog![](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0eWxlPSJ2ZXJ0aWNhbC1hbGlnbjogLTAuMDVlbTsgbWFyZ2luLWxlZnQ6IDBlbTsgbWFyZ2luLXRvcDogMC4xZW07IiB2aWV3Ym94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik03IDdoMTB2MTAiIC8+PHBhdGggZD0iTTcgMTcgMTcgNyIgLz48L3N2Zz4=)](https://github.com/typeerror/elf/blob/main/CHANGELOG.md)\


### AI / Agents

[Skills<img src="data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iZ2Qtc3BhcmtsZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMC44NWVtIiBoZWlnaHQ9IjAuODVlbSIgdmlld2JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0eWxlPSJ2ZXJ0aWNhbC1hbGlnbjogLTAuMWVtOyBtYXJnaW4tbGVmdDogMC4yNWVtOyI+PHBhdGggZD0iTTkuOTM3IDE1LjVBMiAyIDAgMCAwIDguNSAxNC4wNjNsLTYuMTM1LTEuNTgyYS41LjUgMCAwIDEgMC0uOTYyTDguNSA5LjkzNkEyIDIgMCAwIDAgOS45MzcgOC41bDEuNTgyLTYuMTM1YS41LjUgMCAwIDEgLjk2MyAwTDE0LjA2MyA4LjVBMiAyIDAgMCAwIDE1LjUgOS45MzdsNi4xMzUgMS41ODJhLjUuNSAwIDAgMSAwIC45NjNMMTUuNSAxNC4wNjNhMiAyIDAgMCAwLTEuNDM3IDEuNDM3bC0xLjU4MiA2LjEzNWEuNS41IDAgMCAxLS45NjMgMHoiIC8+PHBhdGggZD0iTTIwIDN2NCIgLz48cGF0aCBkPSJNMjIgNWgtNCIgLz48L3N2Zz4=" class="gd-sparkle" />](skills.md)\
[llms.txt](llms.txt)\
[llms-full.txt](llms-full.txt)\


### Developers


**cak**

<span style="margin-top: -0.15em; display: block;"> </span>

Author

<span style="margin-top: -0.15em; display: block;">[](mailto:cak@typeerror.com "Email") [](https://github.com/typeerror "GitHub")</span>


### Community

[Full license](./license.html) <span class="gd-spdx-badge" title="MIT License">MIT</span>\


### Meta

**Requires:** Python `>=3.11`\
[Package Info](package-info.md)
