# check_exists

Adopt this skill: https://proskills.md/skills/other/openauthority-clawthority-examples-skills-check-exists

Page: https://proskills.md/skills/other/openauthority-clawthority-examples-skills-check-exists
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: examples/skills/check_exists/SKILL.md
size: 2477
upstream: https://github.com/openauthority/clawthority/blob/main/examples/skills/check_exists/SKILL.md

````text
---
name: check_exists
version: 1.0.0
author: clawthority
license: MIT-0
description: Checks whether a given path exists in the filesystem, returning a boolean result for both files and directories.
read_when: user asks to check if file exists, verify path exists, check if directory exists, test file existence, path exists
action_class: filesystem.read
---

# /check_exists — Check Path Existence

You are the **check_exists** tool for Clawthority. You check whether a given path exists in the filesystem and return a boolean result.

## What You Do

- Returns `{ exists: true }` if the path exists (file or directory).
- Returns `{ exists: false }` if the path does not exist.
- Does not throw errors for non-existent paths.
- Works for both files and directories.

## When to Trigger

Invoke this tool when the user or agent wants to:
- Verify whether a file or directory exists before reading or writing
- Guard conditional logic on path existence
- Check if a configuration file or output directory is present

## Parameters

| Name   | Type     | Required | Description                           |
|--------|----------|----------|---------------------------------------|
| `path` | `string` | Yes      | Absolute path to check for existence. |

## Result

| Name     | Type      | Description                                     |
|----------|-----------|-------------------------------------------------|
| `exists` | `boolean` | Whether the path exists in the filesystem.      |

## Example Usage

### Check if a file exists

```json
{
  "tool": "check_exists",
  "params": {
    "path": "/project/src/index.ts"
  }
}
```

### Example Response (file exists)

```json
{
  "exists": true
}
```

### Example Response (path does not exist)

```json
{
  "exists": false
}
```

### Check if a directory exists

```json
{
  "tool": "check_exists",
  "params": {
    "path": "/project/dist"
  }
}
```

## Error Handling

| Error Code | Cause                                            |
|------------|--------------------------------------------------|
| `fs-error` | An unexpected filesystem error occurred.         |

Non-existent paths return `{ exists: false }` and do not throw errors.

## Out of Scope

- File type detection (file vs. directory)
- Permission checks
- File metadata (size, modification time)

## Action Class

This tool is classified as `filesystem.read` — a read-only operation that does not modify the filesystem. It is not subject to HITL gating.
````

## File: README.md
upstream: https://github.com/openauthority/clawthority/blob/main/README.md

````text
<p align="center">
  <img src="docs/assets/clawthority-logo.png" alt="Clawthority" width="320">
</p>

# Clawthority

[![OpenClaw Plugin](https://img.shields.io/badge/OpenClaw-plugin-8A2BE2)](https://github.com/openclaw/openclaw)
[![CI](https://github.com/OpenAuthority/clawthority/actions/workflows/e2e.yml/badge.svg)](https://github.com/OpenAuthority/clawthority/actions/workflows/e2e.yml)
[![Version](https://img.shields.io/github/package-json/v/OpenAuthority/clawthority?label=version&color=informational)](package.json)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Node.js >= 18](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6.svg?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](docs/contributing.md)

**A semantic authorization runtime for AI agents. Define what your agent can do, enforce it at the boundary, and keep a human in the loop for what matters.**

Clawthority is a policy engine plugin for [OpenClaw](https://github.com/openclaw/openclaw). It sits between your AI agent and every tool it calls, evaluates rules *before* execution, and - if policy says no - the call is never placed.

```
Agent tool call  ─►  Clawthority  ─►  Allow  │  Deny  │  Ask human  ─►  Audit log
```

> [!NOTE]
> **v1.x - stable API.** The plugin API and policy bundle schema follow [semantic versioning](https://semver.org); breaking changes ship in a future major release. The version badge above reflects the current release (1.3.4).

---

## Contents

- [Why Clawthority](#why-clawthority)
- [What it is - and isn't](#what-it-is--and-isnt)
- [Quickstart](#quickstart)
- [How it works](#how-it-works)
- [Action registry](#action-registry)
- [Human-in-the-loop](#human-in-the-loop)
- [Configuration](#configuration)
- [Budget control](#budget-control)
- [Documentation](#documentation)
- [Development](#development)
- [License](#license)

---

## Why Clawthority

AI agents call tools. When a tool can delete files, send money, or talk to strangers, **who decides whether that call goes through - the model, or you?**

Skill-based safety (instruct the model to "please check first") fails the moment the model is wrong, distracted, or prompt-injected. Clawthority moves the decision **outside the model's loop** - into the code path between the agent and the tool.

| | **The Skill (model-enforced)** | **The Plugin (code-enforced)** |
|---|---|---|
| **Lives in** | Context window - model sees it | Execution path - between agent and tools |
| **Enforces via** | Model reasoning; asks it to comply | Code boundary; intercepts the call |
| **Can be bypassed?** | Yes - prompt injection, loop misfire | No - runs outside the model's loop |
| **Gives you** | Observability + soft stop | Hard enforcement + append-only audit log |

> A skill *asks* the model to enforce. A plugin enforces regardless of what the model decides.

---

## What it is - and isn't

**Clawthority is:**

- A **policy decision + enforcement** layer for tool calls, installed as an OpenClaw plugin.
- A **semantic** authorizer - rules are written against canonical action classes (`filesystem.delete`, `payment.initiate`), not brittle tool-name regexes.
- A **cryptographic capability system** - HITL approvals are SHA-256-bound to `(action_class, target, payload_hash)` at approval time. Param tampering after approval = auto-deny.
- **Two install modes** - `open` (default, implicit permit + critical forbids) for zero-friction installs, and `closed` (implicit deny, explicit permits required) for locked-down production. Stage 1 capability/HITL gates and pipeline-level error handling fail closed in both modes.

**Clawthority isn't:**

- A model-safety or alignment layer. It does not enforce semantic constraints on prompt content, and it does not inspect tool *outputs* for sensitive data.
- A runtime for agents. OpenClaw still decides *which* tools the agent sees; Clawthority decides *whether those calls run*.
- A substitute for good action-class registration. Misregistered tools fall through to `unknown_sensitive_action`, which is forbidden at priority 100 in `closed` mode but **implicitly permitted in `open` mode** unless you add an explicit forbid rule for it in `data/rules.json` — a signal you need to register the alias.
- A full process sandbox. Clawthority enforces **in-band tool calls only** - calls routed through OpenClaw's tool dispatcher. Skills or workspace helpers that call `fs`, `child_process`, or network APIs directly bypass the dispatcher and are out of scope. See [docs/threat-model.md](docs/threat-model.md) for the full boundary definition and recommended mitigations.

---

## Quickstart

Install from npm into the OpenClaw plugins directory:

```bash
mkdir -p ~/.openclaw/plugins/clawthority
cd ~/.openclaw/plugins/clawthority
npm init -y >/dev/null
npm install @clawthority/clawthority
```

Installing the package runs `scripts/post-install.mjs`, which writes a `data/.installed` marker under the plugin root. The marker gates policy activation — see `isInstalled()` in `src/index.ts`. No other files outside the plugin directory are touched.

Register in `~/.openclaw/config.json`:

```json
{ "plugins": ["clawthority"] }
```

> [!NOTE]
> The three companion soft-enforcement skills (`human-approval`, `token-budget`, `whatdidyoudo`) live in a separate `clawthority-skills` repository. They are optional and independent of the plugin.

By default Clawthority runs in **`open` mode** - implicit permit, with a critical-forbid safety net (`shell.exec`, `code.execute`, `payment.initiate`, `credential.read`, `credential.write`, `credential.rotate`). Note: `unknown_sensitive_action` is *not* in this safety net — unregistered tool names are implicitly permitted in `open` mode unless you add an explicit forbid rule for `unknown_sensitive_action` in `data/rules.json`. To fail closed on unknown tools out of the box, run in **`closed` mode** (implicit deny, explicit permits required) by setting the env var before launching your agent:

```bash
export CLAWTHORITY_MODE=closed
```

Mode is read once at activation - restart the agent to change it.

Customise the baseline by dropping hot-reloadable rules into `data/rules.json`:

```json
[
  { "effect": "permit", "action_class": "filesystem.read" },
  { "effect": "forbid", "action_class": "payment.initiate", "priority": 90 },
  { "effect": "forbid", "resource": "tool", "match": "my_custom_tool" }
]
```

Run your agent. A `shell.exec` call now terminates at the boundary:

```
[clawthority] │ DECISION: BLOCKED (cedar/forbid priority=100 rule=action:shell.exec) - Shell execution is unconditionally forbidden
```

Every block - plus every HITL outcome - is appended to `data/audit.jsonl` as structured JSONL with `stage`, `rule`, `priority`, and `mode` fields. See [docs/troubleshooting.md](docs/troubleshooting.md#total-lockout-recovery--everything-is-blocked-i-cannot-fix-the-policy) for the recovery runbook.

> [!TIP]
> `data/rules.json` and `hitl-policy.yaml` hot-reload within ~300ms. Anything else under `src/` requires a gateway restart.

---

## How it works

```
Agent picks a tool → Clawthority intercepts
      │
      │  normalize_action(toolName, params) → { action_class, target, payload_hash }
      │  buildEnvelope(...)                  → ExecutionEnvelope
      ▼
┌──────────────────────── Pipeline ────────────────────────┐
│  Stage 1: Capability Gate                                │
│    • low-risk bypass                                     │
│    • approval_required / TTL / payload binding           │
│    • one-time consumption, session scope                 │
│    • untrusted source + high risk → deny                 │
│                                                          │
│  Stage 2: Constraint Enforcement Engine                  │
│    • protected path che
````
