> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monolex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MonoGuard

> Run the supervised DIFF writer, create timestamped file backups, seed baselines, and inspect recoverable history.

MonoGuard is the file-defense daemon and the DIFF layer's only writer. It
consumes watcher changes, records point-in-time checkpoints, and keeps file
copies for content above the configured threshold. Production use should
install it as a restart-on-crash OS service rather than relying on an
unsupervised foreground process.

*Published contract: `monoguard 0.2.1`, OpenCLIs build
`2026-07-12-192817`. The executing binary, OpenCLIs registry, and public CDN
metadata agree on this release.*

## Quick Start

```bash theme={null}
openclis install monoguard

monoguard --version
monoguard service install
monoguard status
monoguard docs
```

## Complete Command Reference

| Command             | What it does                                                                                         | Effect or controls                                                                                                            |
| ------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `monoguard`         | Prints the embedded full guide.                                                                      | Read-only and safe before state directories exist.                                                                            |
| `start`             | Runs the DIFF writer in the foreground.                                                              | Creates the default config if absent, initializes checkpoint/guard databases, writes the pid lock, and announces the service. |
| `start --takeover`  | Removes a recognized existing pid lock, then starts this process.                                    | **0.2.1 does not signal the old live process.** Do not use it as a safe restart; use supervised service lifecycle instead.    |
| `stop`              | Stops the recognized daemon.                                                                         | Process-state mutation.                                                                                                       |
| `status`            | Reports pid/name verification, heartbeat age, checkpoints, and OS-service state.                     | Observational, but common startup creates missing runtime/database/backup directories before dispatch.                        |
| `service install`   | Registers and starts a supervised launchd, Task Scheduler, or systemd service with restart-on-crash. | Persistent OS service write.                                                                                                  |
| `service uninstall` | Stops and removes the supervisor registration.                                                       | Persistent OS service removal.                                                                                                |
| `service status`    | Shows supervisor state beside pid/name-verified daemon truth.                                        | Observational after common path initialization.                                                                               |
| `history [file]`    | Lists timestamped backup history globally or for one file.                                           | `--limit <n>`, default 20; read-only.                                                                                         |
| `seed <path>`       | Creates baseline backups for files beneath a path.                                                   | Potentially many backup writes; inspect scope first.                                                                          |
| `backup <file>`     | Records one checkpoint immediately.                                                                  | Explicit DIFF/checkpoint write; unchanged content returns no new record.                                                      |
| `docs [topic]`      | Lists or serves embedded AI documentation.                                                           | Read-only; the 0.2.1 package contains the `index` topic.                                                                      |
| `--version`, `-V`   | Prints installed payload identity.                                                                   | Read-only; Clap also provides `--help` and `-h` for every command.                                                            |

## State and Recovery

The current configuration is `~/.monolex/monoguard.toml`. Its `[backup]`
section controls `dir`, `keep_per_file`, `never_delete_base`, `extensions`,
`exclude`, and `file_copy_threshold`. Defaults are `~/monoguard-backups`, ten
versions per file, BASE retention, all extensions, common temporary-file
exclusions, and a 102,400-byte (100 KiB) copy threshold. Do not use older
`~/.config/monoguard/...` paths.

```text theme={null}
configured path changes
        ↓ supervised MonoGuard
checkpoint diffs + large-file copies + DIFF events
        ├── Work Wiki recent/diff/pattern views
        └── history for human recovery
```

There is no event backfill after a dead period. Replaying old watcher events
against today's files would fabricate wrong-dated diffs, so MonoGuard resumes
forward from revival. `status` and `service status` must both be healthy before
calling the DIFF layer live.

`service install` prefers the stable signed
`~/.openclis/bin/monoguard`, registers `ai.monolex.monoguard`, enables run at
load and restart-on-crash, and starts it with the `start` argument. On macOS the
log is `~/Library/Logs/Monolex/monoguard.log`; other platforms use the Monolex
runtime log directory.

During this audit the installed service and daemon reported the same PID,
`installed=true`, `running=true`, and a one-second heartbeat age. That is a
point-in-time runtime proof, not a guarantee for another machine.

## Release Platforms

| Artifact                            | Public binary   | Supervisor boundary                                                             |
| ----------------------------------- | --------------- | ------------------------------------------------------------------------------- |
| `darwin-aarch64`                    | `monoguard`     | launchd; strict code-signature verification passed.                             |
| `linux-x86_64`, `linux-aarch64`     | `monoguard`     | systemd through `lib-service`.                                                  |
| `windows-x86_64`, `windows-aarch64` | `monoguard.exe` | Task Scheduler through `lib-service`; stop uses `taskkill` with force fallback. |

## Relationships

| Tool                            | Ownership                                                                                  |
| ------------------------------- | ------------------------------------------------------------------------------------------ |
| [Work Wiki](/ai-clis/work-wiki) | Queries and explains work/diff evidence; MonoGuard writes the DIFF stream                  |
| [MonoFlow](/ai-clis/monoflow)   | Joins watcher/git/code time; MonoGuard supplies backup safety, not temporal interpretation |
| [Monogit](/ai-clis/monogit)     | Git commit/branch structure; not a substitute for uncommitted file snapshots               |
