# Security

SkillLane is designed with local-first, privacy-respecting security principles.

---

## Local-First Architecture

All data is stored locally on your machine:

```
~/.skilllane/
├── config.json       # Your configuration
├── registry.json     # Installed skills index
├── skills/           # Skill files
└── runs/             # Run history
```

- No telemetry
- No external network calls by default
- No data sent to third parties
- You control your data

---

## Secrets Detection

The validator scans all skill files for known secret patterns:

| Pattern | Example | Detection |
|---------|---------|-----------|
| AWS Access Key | `AKIA1234567890ABCDEF` | Regex: `AKIA[0-9A-Z]{16}` |
| AWS Secret Key | `aws_secret_access_key=...` | Regex: `aws[_\-]?secret...` |
| Private Key | `-----BEGIN RSA PRIVATE KEY-----` | Regex: `-----BEGIN...PRIVATE KEY-----` |
| API Key | `api_key=abc123...` | Regex: `api[_\-]?key...` |
| Password | `password=secretpass` | Regex: `password...` |
| Bearer Token | `bearer eyJhbG...` | Regex: `bearer...` |
| GitHub Token | `ghp_abc123...` | Regex: `gh[ps]_...` |
| Slack Token | `xoxb-12345-abcde` | Regex: `xox[bpsar]-...` |

If a secret is detected:
- The validation **fails** with a score penalty of -15 per secret
- The error message identifies the file and secret type
- The skill cannot be installed until the secret is removed

---

## API Authentication

When running the API server, you can enable authentication:

```bash
SKILLLANE_REQUIRE_AUTH=true \
SKILLLANE_API_AUTH_TOKEN=my-secret-token \
skilllane serve
```

### Protected routes

Write operations require a Bearer token when auth is enabled:

```
Authorization: Bearer my-secret-token
```

### Public routes

Read-only operations remain public:

- `GET /health`
- `GET /v1/skilllane/skills`
- `GET /v1/skilllane/skills/:name`
- `GET /v1/skilllane/registry`
- `GET /v1/skilllane/registry/stats`
- `GET /v1/skilllane/doctor`

---

## File Size Limits

Individual skill files are limited to **1MB**. Files exceeding this limit generate a warning during validation. This prevents accidental inclusion of large binary data.

---

## Git Clone Security

When installing from a git URL, SkillLane:

1. Clones with `--depth 1` (shallow clone only)
2. Clones to a temporary directory
3. Validates the content before copying
4. Cleans up the temporary directory

No git history is retained in the installed skill.

---

## Best Practices

1. **Never commit secrets to skills.** Use the validator to catch them.
2. **Enable auth for production API servers.** Set `SKILLLANE_REQUIRE_AUTH=true`.
3. **Review skills before installing.** Read `SKILL.md` and `tools.json` to understand what a skill does.
4. **Use `--strict` validation in CI.** Catch issues before publishing.
5. **Keep `~/.skilllane/` private.** It may contain your installed skills and run history.
