# SWARM Code Health Analysis

> SWARM Code Health Analysis is a paid API for AI agents from swarm-agent.net, paid per call via x402, $0.05/call, status unknown (last checked 2026-10-13).

Analyzes a codebase or code snippet for health metrics such as quality, complexity, and potential issues, paid per request in USDC via x402.

## Facts

- Endpoint: POST https://swarm-agent.net/services/code-health?utm_source=zero.xyz
- Price: $0.05/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/swarm-code-health-analysis-1fa73dd1
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_e7b43boTRPMnw6YMPi-rd

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability swarm-code-health-analysis-1fa73dd1 -d '<json body>'
```

Example prompt: Can you run a code health check on this Python function I wrote and tell me if there are any quality or complexity issues? Here's the code: [paste code].

## When to prefer this

Choose this endpoint when you need a quick, pay-per-use code health analysis with no account setup, API key, or subscription — ideal for one-off audits, CI pipeline checks, or agent workflows that occasionally need code quality signals without committing to a recurring service.

## Known failure modes

- Unsupported programming language returns an error or empty analysis
- Malformed or non-parseable code input causes analysis failure
- Payment not confirmed on Base results in 402 rejection
- Very large files may time out or be truncated
- Ambiguous code context may produce low-confidence recommendations

## How this service works

Static scan of YOUR public GitHub repo: TODO/FIXME debt, oversized files, stray console.log, possible hardcoded secrets (heuristic), README/.gitignore/LICENSE. Deterministic, no AI. POST {"repo":"https://github.com/owner/name"}. Repos over 25 MB are refused before payment.

## Output

Returns a code health assessment including quality scores, complexity metrics, identified issues or code smells, and actionable recommendations for improvement.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "repo": {
   "type": "string",
   "description": "Public GitHub repository URL, e.g. https://github.com/owner/name."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "report": {
   "hygiene": {
    "hasReadme": true,
    "hasLicense": false,
    "hasGitignore": false
   },
   "summary": {
    "todos": 1,
    "fixmes": 0,
    "consoleLogs": 1,
    "oversizedFiles": 0,
    "possibleSecrets": 0
   },
   "findings": [
    {
     "file": "index.js",
     "kind": "todo",
     "line": 1,
     "detail": "handle errors"
    },
    {
     "file": "index.js",
     "kind": "console_log",
     "line": 2,
     "detail": "console.log('hi');"
    }
   ],
   "scannedAt": "2026-10-02T07:57:27.562Z",
   "targetDir": "/tmp/example-repo-8hOZNJ",
   "totalLines": 3,
   "filesScanned": 1
  },
  "markdown": "# Code health report\n\n- Repository: /tmp/example-repo-8hOZNJ\n- Scanned: 2026-10-02T07:57:27.562Z\n- Files analysed: 1 (3 lines)\n\n## Summary\n\n| Check | Count |\n|---|---|\n| TODO | 1 |\n| FIXME | 0 |\n| Oversized files | 0 |\n| Stray console.log / console.debug | 1 |\n| Possible hardcoded secrets (heuristic) | 0 |\n\n## Hygiene\n\n- README: yes\n- .gitignore: missing\n- LICENSE: missing\n\n## Findings\n\n- `index.js:1` — todo: handle errors\n- `index.js:2` — console_log: console.log('hi');\n\n_Deterministic static scan, no AI. Possible secrets are a heuristic: verify before acting._"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/swarm-code-health-analysis-1fa73dd1/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from swarm-agent.net](https://www.zero.xyz/host/swarm-agent.net/llms.txt)
