Back
12/61
Lesson 12
8 min

UBS: Code Quality Guardrails

Catch bugs before they reach production

New to ACFS?

Complete the setup wizard first to get the most from these lessons.

Go to Choose Your OS
Goal

Learn to catch bugs before they reach production with UBS.

What Is UBS?

UBS (Ultimate Bug Scanner) is your safety net before every commit. It scans your code for common bugs, security issues, and anti-patterns that might slip through during development.

Think of it as a code review bot that catches issues in seconds, not hours.

Security Scanning

XSS, injection, and OWASP vulnerabilities

Bug Detection

Null safety, async/await, type issues

Fast Feedback

Scan a file in under 1 second

Multi-Language

TypeScript, Python, Rust, Go, and more

The Golden Rule

Run ubs before every commit.

Exit 0 = safe to commit. Exit >0 = fix issues first.

Essential Commands

Scan a specific file (fastest)
Scan a directory
Scan staged files before commit
Filter by language (3-5x faster)
Scan whole project (ignores node_modules)
Pro Tip
Always scope to changed files when possible. ubs file.ts runs in under 1 second, while ubs . may take 30+ seconds.

Understanding Output

UBS output follows a consistent format:

ubs output
⚠️ Null Safety (3 errors)
src/api/users.ts:42:5 – Possible null dereference
💡 Use optional chaining: user?.profile
src/api/users.ts:87:12 – Unchecked array access
💡 Add bounds check before accessing array[i]
⚠️ Security (1 error)
src/api/auth.ts:23:8 – SQL injection risk
💡 Use parameterized queries instead of string concat
Exit code: 1
file:line:colExact location of the issue
\ud83d\udca1Suggested fix
Exit code 0/1Pass (safe) / Fail (needs fixes)

Bug Severity Guide

Critical

  • Null safety violations
  • XSS/Injection vulnerabilities
  • Async/await issues
  • Memory leaks

Always fix immediately

Important

  • Type narrowing issues
  • Division by zero risks
  • Resource leaks
  • Missing error handling

Fix before production

Contextual

  • TODO/FIXME comments
  • Console.log statements
  • Unused variables
  • Magic numbers

Use judgment

The Fix Workflow

ubs src/utils/helpers.ts
A well-written file passes with zero findings
Files to Scan
src/utils/helpers.ts84 lines
Terminal
$ ubs src/utils/helpers.ts

Clean Code Scenario

A well-written file passes with zero findings

Pre-Commit Integration

For maximum safety, add UBS to your pre-commit workflow:

bash
1# In your workflow:
2$ git add .
3$ ubs $(git diff --name-only --cached)
4# If exit 0: proceed with commit
5# If exit 1: fix issues first
6
7$ git commit -m "feat: add user auth"
Note
ACFS agents are trained to run ubs automatically before committing. You get this protection by default!

Try It Now

bash
1# View session logs
2$ ubs sessions --entries 1
3
4# Scan your project
5$ ubs .
6
7# Get help
8$ ubs --help

Ready to level up?

Mark complete to track your learning progress.