A small command-line app that fetches a GitHub user's recent public activity and
renders it in the terminal. It is built with .NET 11,
System.CommandLine and
ErrorOr, following the same layered,
railway-oriented design as
phatngth-dev/todo-cli.
This is the roadmap.sh GitHub User Activity project.
github-activity <username>fetches recent public events from the GitHub API.- Human-readable descriptions for pushes, issues, pull requests, comments, stars, forks, branches/tags, releases, collaborators, wiki changes and more.
--typefilter with friendly aliases (push,issues,pull-request,watch,fork, ...) or raw GitHub event names (PushEvent).--limitto control how many events are requested (1-100, default 30).- Optional
GITHUB_TOKENauthentication to raise the API rate limit. - Friendly validation, not-found, rate-limit, network, timeout and malformed-JSON errors.
- No third-party HTTP or JSON packages: only
HttpClientandSystem.Text.Jsonfrom the base class library. - Unit and integration test suites.
- .NET 11 SDK or later.
dotnet restore github-activity-cli.slnx
dotnet build github-activity-cli.slnxRun from source:
dotnet run --project src/GitHubActivity.Cli -- torvalds --limit 5Run the built executable:
dotnet src/GitHubActivity.Cli/bin/Debug/net11.0/github-activity.dll torvaldsFramework-dependent publish:
dotnet publish src/GitHubActivity.Cli/GitHubActivity.Cli.csproj -c Release -o publish
./publish/github-activity torvaldsSelf-contained single-file publish (Linux x64 example):
dotnet publish src/GitHubActivity.Cli/GitHubActivity.Cli.csproj \
-c Release \
-r linux-x64 \
--self-contained true \
-p:PublishSingleFile=true \
-o publish/linux-x64
./publish/linux-x64/github-activity torvaldsThe published executable is named github-activity.
Usage:
github-activity <username> [--limit <count>] [--type <event>]
github-activity help
Arguments:
<username> The GitHub username to look up.
Options:
--limit <count> Maximum number of events to fetch (1-100, default 30).
--type <event> Filter by event type.
--help Show help and usage information.
--version Show version information.
Environment:
GITHUB_TOKEN Optional GitHub token used to authenticate API requests.
$ github-activity torvalds --limit 3
Recent activity for 'torvalds' (3 events):
OCCURRED (UTC) ACTIVITY
------------------- --------
2026-12-05 21:14:20 Pushed to torvalds/linux (master)
2026-12-05 02:18:27 Pushed to torvalds/linux (master)
2026-12-04 21:22:58 Pushed to torvalds/linux (master)$ github-activity octocat --type watch --limit 10
Recent activity for 'octocat' (2 events):
OCCURRED (UTC) ACTIVITY
------------------- --------
2026-01-02 02:00:00 Starred octocat/hello-world
2026-01-01 18:30:00 Starred some-org/awesome-project$ github-activity octocat --type issues
Recent activity for 'octocat' (1 event):
OCCURRED (UTC) ACTIVITY
------------------- --------
2026-01-02 02:00:00 Opened a new issue #12 "Fix login" in octocat/hello-worldOther formatted activity lines include:
Merged pull request #7 "Add feature" in octocat/hello-world
Published release v1.2.0 in octocat/hello-world
Forked octocat/hello-world to someone/hello-world
Added new-collaborator to octocat/hello-world
--type accepts these friendly aliases:
| Alias | GitHub event |
|---|---|
push |
PushEvent |
issue, issues |
IssuesEvent |
pull-request, pull, pr |
PullRequestEvent |
review |
PullRequestReviewEvent |
review-comment |
PullRequestReviewCommentEvent |
watch, star |
WatchEvent |
fork |
ForkEvent |
create |
CreateEvent |
delete |
DeleteEvent |
release |
ReleaseEvent |
public |
PublicEvent |
member |
MemberEvent |
comment, issue-comment |
IssueCommentEvent |
commit-comment |
CommitCommentEvent |
wiki, gollum |
GollumEvent |
sponsorship |
SponsorshipEvent |
all |
no filter |
Raw event names such as PushEvent are also accepted (case-insensitive).
github-activity --help
github-activity --version
github-activity helpUnauthenticated GitHub API requests are limited to 60 requests per hour. Set a personal access token to raise the limit:
export GITHUB_TOKEN=ghp_your_token_here
github-activity torvalds --limit 30The token is read from the environment, never from command-line arguments, and
is sent as a Bearer authorization header.
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Validation, not-found, API, network or response failure |
2 |
Invalid usage, such as an unknown --type filter |
Command-line parse errors (missing username, unknown options, non-numeric
limits) are reported by System.CommandLine with a non-zero exit code and usage
text.
Error codes use dot-separated segments so each failure is identifiable.
| Code | Type | Meaning |
|---|---|---|
github.username.empty |
Validation | Username is missing or whitespace |
github.username.invalid |
Validation | Username violates GitHub's rules |
github.limit.invalid |
Validation | Limit is outside 1-100 |
github.user.not_found |
NotFound | GitHub returned 404 for the user |
github.rate_limited |
Custom 429 |
GitHub API rate limit was exceeded |
github.api.failed |
Custom 502 |
GitHub returned another non-success status |
github.network.failed |
Custom 502 |
The API could not be reached |
github.timeout |
Custom 504 |
The API request timed out |
github.response.invalid |
Custom 502 |
The API response was empty or malformed |
usage.type.invalid |
Custom 400 |
Unknown --type filter |
The codebase is organised as vertical slices. The CLI parses input, renders output and composes the application handler; the application layer owns validation, filtering and error semantics; the infrastructure layer talks to GitHub.
src/
GitHubActivity.Application/ Business logic
Features/
GetUserActivity/GetUserActivityHandler Validate input, fetch, filter
GetUserActivity/GetUserActivityRequest Limit and event-type query
Shared/GitHubUserActivity Event model
Shared/GitHubEventPayload Per-event payload details
Shared/GitHubUsername GitHub username rules
Shared/IGitHubActivityClient HTTP client contract
Infrastructure/GitHubActivityClient GitHub REST API adapter
GitHubActivity.Cli/ Presentation only
Commands/ActivityCommandHandlers Calls the slice and renders results
Commands/ActivityEventFormatter Event -> human-readable sentence
Commands/ActivityFilterParser Friendly alias -> GitHub event name
GitHubActivityCli.cs System.CommandLine command tree
Program.cs Startup and HttpClient configuration
tests/
GitHubActivity.Application.Unit.Tests/ Handler and validation tests
GitHubActivity.Cli.Tests/ Formatter, filter, routing tests
GitHubActivity.IntegrationTests/ HTTP adapter and end-to-end CLI tests
| Concern | Location |
|---|---|
| Parse commands, arguments and options | GitHubActivity.Cli with System.CommandLine |
| Show help, format events and errors | GitHubActivity.Cli |
| Validate usernames and limits | GetUserActivityHandler |
| Apply event-type filters | GetUserActivityHandler |
| Define the client contract and event model | GitHubActivity.Application/Features/Shared |
| Call the GitHub REST API and map JSON | GitHubActivity.Application/Infrastructure/GitHubActivityClient |
Configure HttpClient, token and timeout |
GitHubActivity.Cli/Program.cs |
The handler returns ErrorOr<T> instead of throwing for expected failures. The
CLI uses Match to compose and render the result, while unexpected failures are
still surfaced as exceptions at the process boundary.
The client calls:
GET https://api.github.com/users/{username}/events?per_page={limit}
Accept: application/vnd.github+json
X-GitHub-Api-Version: 2022-11-28
User-Agent: github-activity-cli/1.0
GitHub's public event feed currently omits commit details for many
PushEvent payloads. When GitHub includes a commit count, the output reads
Pushed N commits to owner/repo; otherwise the formatter shows the branch, for
example Pushed to owner/repo (main). No extra requests are made just to obtain
a commit count, which keeps the CLI inside the API rate limit.
dotnet test github-activity-cli.slnxTest suites:
- Application unit tests cover username and limit validation, trimming, default limits, filtering and propagation of client errors.
- CLI unit tests cover formatting for every supported event type, long-title truncation, filter aliases, command routing, options, and exit codes.
- Integration tests cover HTTP request construction, JSON mapping,
404, rate limiting,500, malformed JSON, network and timeout failures, plus full CLI runs against a stubbed GitHub endpoint.