# Generic ArtifactGuard Agent Workflow

This workflow can be adapted for any AI coding agent that can run shell commands.

## Purpose

ArtifactGuard prevents AI-assisted coding sessions from silently leaving temporary or sensitive artifacts behind.

Use it as a lightweight session lifecycle:

```text
start snapshot -> agent work -> status/report -> safe cleanup -> final cleanup summary
```

## Start of Session

Run before artifact-producing work:

```bash
artifact-guard start
```

This captures a baseline snapshot of the workspace.

## During Session

Run when you need to inspect what changed:

```bash
artifact-guard status
```

Review categories:

- `Source changes`: intended project edits
- `Temporary artifacts`: safe cleanup candidates if created during the session
- `Sensitive / needs review`: never delete automatically without explicit policy
- `Deliverables`: keep and report path
- `Unknown / needs review`: inspect before deleting

## End of Session

Always generate a cleanup report before final response:

```bash
artifact-guard finish --report
```

For automatic safe cleanup:

```bash
artifact-guard finish --delete-safe --report
```

For user-reviewed cleanup:

```bash
artifact-guard finish --interactive --report
```

## Safety Boundary

ArtifactGuard only deletes files classified as both:

- `temporary`
- `created`

It does not delete:

- source changes
- Git-tracked files
- sensitive files
- deliverables
- unknown files
- modified files
- deleted-file records

## Suggested Agent Instruction

```md
When a task may create temporary artifacts, run `artifact-guard start` before work. Before the final response, run `artifact-guard finish --report`. If safe cleanup is approved, use `artifact-guard finish --delete-safe --report`; otherwise use `artifact-guard finish --interactive --report`. Include a concise cleanup summary in the final response.
```

## Final Response Examples

```text
Cleanup: ArtifactGuard deleted 3 safe temporary artifacts and wrote .artifact-guard/report.md.
```

```text
Cleanup: ArtifactGuard kept 1 sensitive file and 2 unknown files for manual review; report: .artifact-guard/report.md.
```

```text
Cleanup: ArtifactGuard found no temporary artifacts; report: .artifact-guard/report.md.
```
