This page covers moodle-cli’s own config file, session cache and global flags. For the general shape these ideas take across all three CLIs, see Configuration.

Config file

moodle-cli stores base_url in a YAML file at ~/.config/moodle-cli/config.yaml. The first run that needs a base URL and finds none prompts for it (in an interactive terminal only) and writes it there.
config.yaml
moodle-cli looks for a config file in this order, and reads the first one it finds:
  1. The path in MOODLE_CONFIG, if that variable is set.
  2. ./config.yaml in the current directory.
  3. ~/.config/moodle-cli/config.yaml.
Only the first file found is read — settings from other locations are not merged in. Scripting this? See Moodle CLI for scripts and agents for the full environment variable table, including how to point the CLI at a session without a browser.

Session cache

A validated session — a few profile fields alongside what’s needed to sign you back in — is cached at ~/.cache/moodle-cli/session.json, encrypted at rest, with the file and its containing directory restricted to your user. The cache expires after 24 hours; an expired or missing cache triggers a fresh sign-in. Pass --no-cache to skip the cache for a single command: it neither reads a cached session nor writes the one it obtains.

Global flags

These flags work on every command. See Output formats for --json/--yaml/--table/--fields, and Mutations for --yes and --dry-run. --limit and --days are declared once on the program itself. A value you pass wins over the command’s own default, wherever you put it on the command line; leave it out and the command falls back to its own default: moodle due, for example, defaults --days to 14 and --limit to 20.

--verbose

-v / --verbose writes one line per request to stderr, naming what was requested and how long it took. It never logs your session cookie or an MCP (Model Context Protocol) access token. Scripting this? See Moodle CLI for scripts and agents for --fields and --pretty.