Set up from the command line
Create projects, keys, goals, funnels, replay settings and log drains from a terminal, check that events arrive, and hand setup to a coding agent.
The Little Friend CLI sets up a project from your terminal. Create the project, print the snippet for your framework, add keys, goals and funnels, set up session replay, the door and a Vercel log drain, then check that events arrive. A coding agent can run every step.
Install and sign in
The CLI needs Node 22 or later. Run it with npx, so nothing is installed in your project:
npx @littlefriend/cli loginYour browser opens on Little Friend. Approve the CLI there, and it acts with your role in each of your workspaces. If the browser doesn't open, the CLI prints the address to visit. It waits up to 5 minutes.
The sign-in is saved in ~/.littlefriend/credentials.json, readable only by you, and its access token refreshes on its own. logout revokes it and deletes the file. You can also install the CLI once and call it by name:
npm install -g @littlefriend/cli
littlefriend whoamiThe examples below use littlefriend. With npx, type npx @littlefriend/cli in its place.
Choose the workspace and project
Most commands work on one project. Name it with a flag, or set the environment variable once for your shell.
| Flag or environment variable | What it does |
|---|---|
--workspace <workspace>LITTLEFRIEND_WORKSPACE | The workspace a command works in, by id, slug or name. Optional when you belong to one. |
--project <project>LITTLEFRIEND_PROJECT | The project a command works on, by id, site key, name or domain. Optional when there is only one. |
--json | Machine output on stdout, errors included. |
--api <url>LITTLEFRIEND_API | The API to talk to. Defaults to api.littlefriend.io. |
LITTLEFRIEND_TOKEN | An access token to use instead of signing in, for CI. |
Errors go to stderr with a non-zero exit code and the API's own message, so scripts can stop on them. With --json, they are also printed on stdout as { "error": { "code", "message" } }.
Account
Sign in once per computer. The CLI refreshes its access token on its own.
# Sign in through your browser.
littlefriend login
# Show the account you are signed in as.
littlefriend whoami
# Revoke the sign-in and delete the saved credentials.
littlefriend logoutWorkspaces and projects
A project is one site or app, with its own public site key. A workspace holds your projects and your team.
# List the workspaces you belong to.
littlefriend workspaces list
# List a workspace's projects.
littlefriend projects list --workspace Acme
# Create a project and print its id and public site key. Without --origin, it allows the domain and its www host over https. If a project already has the domain, it prints that one.
littlefriend projects create --name "Acme" --domain acme.com \
--mode journey --origin https://acme.com
# Show a project's settings.
littlefriend projects get --project Acme
# Show the project, whether events arrive, and why any requests were refused.
littlefriend projects check --project acme.com
# Change settings. Takes the same flags as create, adds or removes one origin at a time, and edits the ignored routes, /api by default.
littlefriend projects update --timezone America/Chicago
# Delete a project and all its data.
littlefriend projects delete --project Acme --yes
# List the native apps allowed to send data to the project.
littlefriend apps list
# Allow an app by its bundle id or package name, up to 20 per project. Prints the new list.
littlefriend apps add com.acme.shop
# Stop accepting data from an app.
littlefriend apps remove com.acme.shopInstall
Prints what to add to your site, with your site key filled in, and the Content Security Policy lines it needs. Frameworks: html, next, nuxt, sveltekit, astro, remix, react, vue, angular, wordpress, npm.
# Print the code for your framework. Without --framework, it picks one from the current folder.
littlefriend snippet --framework next --mode journey --replayKeys
Server keys (lfs_) send outcomes from your backend, edge keys (lfe_) send requests from your edge, and read keys (lfr_) read reports. A secret is shown once. With --write-env, it goes straight into that file and is never printed.
# List the project's keys, without their secrets.
littlefriend keys list
# Create a key. With --write-env, add it to that file as NAME, unless the file already sets NAME.
littlefriend keys create --kind server --label "API" \
--write-env .env --env-name LF_SERVER_KEY
# Revoke a key. Requests that use it are refused from then on.
littlefriend keys revoke key_XXXXXXXX --yesGoals
A goal counts a page view or an event, from the moment you save it.
# List the project's goals. --archived includes archived ones.
littlefriend goals list
# Create a goal. With --source server, it counts only events your server sends. --server-confirmed also marks it that way in reports. --prop, up to 3 times, also requires a property value.
littlefriend goals create --name "Purchase" --event order.completed --source server --server-confirmed
# Change a goal. Its version number goes up. --prop or --no-props alone replaces only its property conditions. --restore brings back an archived goal.
littlefriend goals update goal_XXXXXXXX --name "Paid order"
# Archive a goal, so past reports can still name it.
littlefriend goals delete goal_XXXXXXXX --yesFunnels
A saved funnel is 1 to 8 steps in order: route:/path, event:<name> or goal:<goalId>. Funnels need journey mode.
# List saved funnels.
littlefriend funnels list
# Save a funnel.
littlefriend funnels create --name "Signup" \
--step route:/pricing --step event:signup.start --step goal:goal_XXXXXXXX
# Rename a funnel or replace its steps.
littlefriend funnels update fnl_XXXXXXXX --name "Signup flow"
# Delete a saved funnel.
littlefriend funnels delete fnl_XXXXXXXX --yes
# Run a saved funnel, or steps you pass. Dates are YYYY-MM-DD.
littlefriend funnels report fnl_XXXXXXXX --from 2026-09-01 --to 2026-09-30Session replay
Replay needs journey mode. In replay set, --unmask, --block and --exclude replace that list, so pass every item you want to keep. To change one item, use --add-unmask, --remove-unmask and the same pairs for block and exclude. --clear-unmask and the like empty a list.
# Show the replay settings.
littlefriend replay get
# Turn replay on, for a percent of journey sessions.
littlefriend replay enable --rate 50
# Set shown text, hidden elements and pages never recorded. --unmask-preset adds the labels and headings preset.
littlefriend replay set --unmask nav --unmask h1 \
--block .support-chat --exclude /account
# Turn replay off.
littlefriend replay disableThe door
The door decides which AI agents get in, in your Worker, proxy or server. Presets: open, no_training, verified_only, commerce. Every project starts in dry run, which records what the door would do and changes no response.
# Show the door's rules and mode.
littlefriend door get
# Replace the rules with a preset, switch between dry run and live, or both. --yes confirms replacing custom rules.
littlefriend door set --preset no_training --mode dry_run
# Show what the door would decide for one request, or with no --ua, for the last 7 days of agent requests.
littlefriend door simulate --path /blog \
--ua "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.2; +https://openai.com/gptbot)"Log drains
A Vercel log drain reports every request your site serves, crawlers and AI agents included, with no code change.
# List the project's drains.
littlefriend drains list
# Create a drain. Prints what to paste into Vercel, once.
littlefriend drains create --provider vercel
# New key and secret. The old pair works for 24 more hours, or as long as --grace-hours says.
littlefriend drains rotate drn_XXXXXXXX
# Revoke a drain and its keys.
littlefriend drains delete drn_XXXXXXXX --yesCheck your data
Confirm an install works, then glance at the numbers. verify counts events from the last --since minutes. It exits 0 when one arrives and 1 when the wait runs out, so a script can stop on it.
# Wait for an event, then print its time, route and source. --source counts only that source.
littlefriend verify --source browser --since 10 --wait 120
# Print quick numbers from a report, for every platform or one.
littlefriend report pages --from 2026-09-01 --to 2026-09-30
# Print the agent setup guide.
littlefriend guideSet up with a coding agent
The agent setup guide takes a coding agent through every step for one product: reading the repo, choosing the mode, installing the snippet, naming events, creating goals and funnels, replay, server events, the door and a log drain. It ends with a report of what the agent set up and what still needs a person.
- Read it at littlefriend.io/agent-setup.md.
- Or print it with
littlefriend guide.
Add Little Friend to this repo. Follow the guide at
https://littlefriend.io/agent-setup.md step by step, and end with its report.The agent signs in with littlefriend login like anyone else, so you approve it in your browser once. Secret keys go into your env file and are never printed.