DevSafe / Docs
Docs AI Safety devsafe diagnose

The doctor's visit for
your AI tooling.

Run devsafe diagnose before anything else. It scans your project for secrets that AI coding tools can see, tells you exactly what's exposed, and recommends what to do about it. Free. No account needed.

Usage

terminal
$ devsafe diagnose

That's it. No flags, no configuration, no account. Just run it in any project directory and DevSafe will scan for AI-related secret exposure.

What it checks

devsafe diagnose inspects four exposure paths. These are the ways secrets end up visible to AI coding tools, often without the developer realizing it.

1. Environment files readable by AI context windows

AI tools read your project files to provide suggestions. If your .env file is in the project root (and not excluded from the tool's context), the AI can see every secret in it. API keys, database passwords, auth tokens. diagnose checks whether your .env files are accessible to each detected AI tool's context window.

2. MCP server configs with hardcoded tokens

MCP (Model Context Protocol) servers connect AI tools to external services. Many developers hardcode API tokens directly into MCP config files instead of using environment variable references. diagnose scans MCP configurations for plaintext secrets.

3. AI session logs that captured secrets

When an AI tool reads a secret during a session, that secret may persist in session logs, conversation history, or cache files on your machine. diagnose checks these log locations for leaked secret material.

4. Git-tracked secrets that AI tools can read

If a secret was committed to your git history (even if later removed from the working tree), AI tools that index your repository can still find it. diagnose checks for secrets in tracked files and warns about historical exposure.

Detected AI tools

diagnose automatically detects which AI coding tools are installed by looking for their configuration files and directories:

If a tool isn't installed, it's skipped. If none are detected, diagnose tells you so and exits cleanly.

Example output

terminal
$ devsafe diagnose

DevSafe AI Diagnosis
scanning ~/Projects/api-server

Detected AI tools:
 Claude Code      .claude/, CLAUDE.md
 Cursor           .cursor/rules/
 GitHub Copilot   .github/copilot-instructions.md

Exposure path 1: .env files in AI context
  ⚠ EXPOSED  .env readable by Claude Code context window
  ⚠ EXPOSED  .env readable by Cursor context window
  found 4 secrets: STRIPE_SK, DATABASE_URL, RESEND_KEY, JWT_SECRET

Exposure path 2: MCP configs with hardcoded tokens
  ⚠ EXPOSED  .cursor/mcp.json contains 2 plaintext tokens
  ✓ clean   .claude/mcp_servers.json uses env var references

Exposure path 3: AI session logs
  ⚠ FOUND   3 secrets captured in Cursor session logs
           ~/.cursor/logs/2026-06-28-session.log

Exposure path 4: Git-tracked secrets
  ✓ clean   no secrets found in tracked files

────────────────────────────────────────
  4 exposures found across 3 paths

Recommended next steps:
  1. Run devsafe shield to block .env from AI context windows
  2. Run devsafe lockbox import .env to encrypt secrets at rest
  3. Run devsafe mcp-scan for a deeper MCP config audit
  4. Delete session logs: ~/.cursor/logs/2026-06-28-session.log

What to do with the results

diagnose tells you what's wrong. The other DevSafe commands fix it.

Think of diagnose as the examination and these commands as the treatment. Run the diagnosis first, then address each finding.

Start here, every time.

devsafe diagnose is the recommended first command for any project. It takes seconds, costs nothing, and gives you a clear picture of your AI secret exposure before you make any changes. If you only run one DevSafe command, make it this one.

How it works

diagnose runs entirely on your machine. It does not send any data anywhere. Here is what happens when you run it:

No network requests. No telemetry. No account required. The binary does everything locally.

Exit codes

This makes diagnose easy to use in CI pipelines or git hooks. A non-zero exit means something needs attention.