AI Features

Falcon includes AI-powered analysis capabilities to assess code quality, detect provenance, discover conventions, and predict risks.

1. AI Code Score

Run falcon score to get a comprehensive quality assessment of your project.

What it measures

The AI score evaluates 6 dimensions with the following weights:

Example command and output

$ falcon score .
Analyzing project...

AI Score: 82/100 (B)

Dimension breakdown:
  Maintainability  ████████████████░░░░  78%
  Testability      ██████████████████░░  85%
  Performance      █████████████████░░░  82%
  Security         ████████████████░░░░  80%
  Consistency      ███████████████████░  92%
  Documentation    ████████████░░░░░░░░  62%

Suggestions: 4 improvements found

Flags

Grade scale

GradeScore
A90+
B80+
C70+
D60+
F<60

2. Code Provenance

Run falcon provenance to detect the origin of code in your project.

What it detects

Heuristic signals

The detector looks for patterns such as:

Flags

Example output

$ falcon x provenance . --verbose
Provenance analysis:

  lib/main.dart           human-written
  lib/services/api.dart   AI-generated
  lib/models/user.g.dart  code-generated
  lib/widgets/home.dart   unknown

Summary: 45% human, 30% AI, 15% generated, 10% unknown

3. Convention Detection

Run falcon conventions to auto-detect patterns in your codebase.

What it detects

Architecture patterns

State management

Example output

$ falcon x conventions .
Detected conventions:

  Architecture:  Feature-First (lib/features/*)
  State:         Riverpod
  Naming:        snake_case files, PascalCase classes
  Error handling: try/catch with rethrow

4. Drift Detection

Run falcon drift to find new code that deviates from established patterns.

What drift means

Drift occurs when newly added or changed code does not follow the conventions and patterns already established in the project. Falcon compares recent changes against the baseline to flag inconsistencies.

Flags

Example output

$ falcon x drift . --since HEAD~1
Drift analysis (since HEAD~1):

  lib/features/auth/login_bloc.dart
    - Uses setState instead of BLoC (project uses Riverpod)
    - Naming: login_bloc vs convention loginBloc

  lib/widgets/new_button.dart
    - Missing error boundary (project convention)

5. Risk Prediction

Run falcon predict to identify potential risks in your codebase.

Risk categories

Output format

Each risk shows probability, timeframe, and evidence.

Example output

$ falcon x predict .
Risk prediction:

  MemoryLeak (72%)
    Timeframe: Medium-term
    Evidence: StreamController in lib/services/socket.dart:45 not disposed

  CrashAtScale (58%)
    Timeframe: Short-term
    Evidence: Potential null in lib/screens/profile.dart:112

  SecurityBreach (41%)
    Timeframe: Long-term
    Evidence: API key in lib/config.dart:8

6. Auto Rule Discovery

Run falcon discover-rules to get proposed new rules based on patterns in your codebase.

How it works

Falcon analyzes your project for recurring patterns and anti-patterns, then proposes custom rules you can add to your configuration. Each rule includes a confidence score.

Example output

$ falcon x discover-rules .
Discovered rules:

  1. prefer_const_constructors_in_widgets (confidence: 0.92)
     "Use const constructors for stateless widgets when possible"
     Matches: 47 files

  2. no_print_in_production (confidence: 0.88)
     "Avoid print() in lib/; use debugPrint or logger"
     Matches: 12 files

  3. bloc_dispose_in_dispose (confidence: 0.85)
     "Close BLoC/Cubit in dispose()"
     Matches: 8 files