forge-guard 0.3.5

Pre-deployment smart contract auditing framework for Foundry
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
# ๐Ÿ”’ Forge Guard

> **The most comprehensive pre-deployment smart contract auditing framework for Foundry.**

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Rust](https://img.shields.io/badge/Rust-1.85%2B-orange)](https://www.rust-lang.org)
[![Foundry](https://img.shields.io/badge/Foundry-compatible-blue)](https://book.getfoundry.sh/)
[![CI](https://github.com/codetibo/forge-guard/actions/workflows/ci.yml/badge.svg)](https://github.com/codetibo/forge-guard/actions/workflows/ci.yml)
[![Nightly Audit](https://github.com/codetibo/forge-guard/actions/workflows/nightly-audit.yml/badge.svg)](https://github.com/codetibo/forge-guard/actions/workflows/nightly-audit.yml)
[![Dependabot](https://img.shields.io/badge/dependabot-enabled-025E8C?logo=dependabot)](https://github.com/codetibo/forge-guard/blob/main/.github/dependabot.yml)
[![Crates.io](https://img.shields.io/crates/v/forge-guard?logo=rust&label=version)](https://crates.io/crates/forge-guard)
[![Changelog](https://img.shields.io/badge/changelog-latest-blue?logo=github)](CHANGELOG.md)

---

## ๐Ÿ“‹ Table of Contents

- [Overview]#overview
- [Key Features]#key-features
- [Milestone Summary]#milestone-summary
- [Installation]#installation
- [Quick Start]#quick-start
- [All Commands]#all-commands
- [Usage Examples]#detailed-usage-examples
- [Configuration]#configuration
- [Architecture]#architecture
- [Security Checks]#security-checks
- [Plugin Development]#plugin-development
- [CI/CD Integration]#cicd-integration
- [Performance]#performance
- [Development]#development
- [Supported Chains]#supported-chains
- [Changelog]CHANGELOG.md
- [Contributing]#contributing
- [License]#license
- [Roadmap]#roadmap

---

## Overview

**Forge Guard** transforms security auditing from an optional step into a mandatory pre-deployment process. It blocks unsafe deployments by default while providing detailed vulnerability reports, exploit path analysis, and comprehensive security scoring.

Built with Rust for maximum performance, `forge-guard` integrates directly into your Foundry workflow as a drop-in CLI tool.

### Key Features

- ๐Ÿ” **50+ Vulnerability Checks** โ€” Reentrancy, access control, delegatecall, flash loans, MEV, oracles, signatures, and more
- ๐Ÿ›ก๏ธ **Deployment Guard** โ€” Blocks unsafe deployments by default; `--force` bypass available with warnings
- โœ… **On-Chain Verification** โ€” Auto-verify contracts on Etherscan, Basescan, Arbiscan, and 14 more explorers
- ๐Ÿ“ก **Bytecode Matching** โ€” Compare local vs on-chain bytecode via RPC `eth_getCode` with metadata hash stripping
- ๐Ÿ” **MEV Analysis** โ€” Detect sandwich, flash loan, oracle, and value extraction attack vectors during simulation
- ๐Ÿค– **AI-Powered Auditing** โ€” OpenAI GPT-5, Anthropic Claude 5, and Ollama integration with consensus engine
- โ›“๏ธ **Multi-Chain** โ€” 17 supported EVM chains with auto-detected explorer URLs
- โšก **Parallel Chain Auditing** โ€” `--all-chains` audits all 17 chains concurrently via Rayon with `--max-parallel-chains` concurrency control, producing an aggregated report with chain-labeled findings
- ๐Ÿ”Œ **Plugin Architecture** โ€” Extensible design for custom security rules; built-in + external (IPC subprocess) plugins
- ๐Ÿ“Š **Rich Reports** โ€” Terminal, JSON, and Markdown output with detailed findings, scores, and remediation
- ๐Ÿ’ฅ **Exploit Engine** โ€” Generates attack vectors and proof-of-concept exploit paths
- ๐Ÿฉบ **Project Doctor** โ€” Comprehensive health analysis: Foundry version, Solc version, project structure, dependencies, RPC, compiler settings
- ๐Ÿ”Ž **Dependency Scanner** โ€” 30+ known vulnerability entries covering OpenZeppelin, Solmate, Solady, Chainlink, Wormhole, LayerZero, forge-std, PRBMath, solc, and more
- โšก **High Performance** โ€” Parallel execution via Rayon, filesystem caching, incremental SHA-256 content-hash analysis (unchanged files skipped on re-runs)
- โšก **Quick Mode** โ€” `forge-guard audit --quick` skips parser-heavy checks, ~5x faster for rapid feedback
- ๐Ÿ“‹ **Executive Summary** โ€” `forge-guard audit --summary` shows concise PASS/FAIL verdict with action items
- ๐Ÿ—๏ธ **CI/CD Ready** โ€” Generate pipeline configs for GitHub Actions, GitLab CI, Bitbucket Pipelines, Azure DevOps
- ๐ŸŽฏ **Audit Templates** โ€” Prebuilt profiles (ERC20, ERC721, DeFi, Bridge, Upgradeable) that adjust checks, scoring weights, and readiness gates; custom templates supported
- ๐Ÿ“ฆ **SBOM Generation** โ€” CycloneDX 1.6 / SPDX 2.3 bills of materials with `--ci` GitHub Actions export for supply-chain compliance
- ๐Ÿช **Git Pre-Commit Hook** โ€” One-command install that audits staged `.sol` files and blocks commits with HIGH/CRITICAL findings
- ๐Ÿ”„ **Foundry Config Sync** โ€” `forge-guard doctor --sync` imports `src`/`test`/`lib`/`remappings`/`solc_version` from `foundry.toml`
- ๐Ÿ”Œ **External Analyzer Import** โ€” `forge-guard import` ingests Slither, Mythril, and Semgrep JSON results with severity mapping, dedup, and unified reporting
- ๐Ÿ“ข **Webhook Notifications** โ€” `forge-guard notify` sends Slack/Discord alerts with rich payloads; `--notify` on audit/deploy/deploy-safe
- โ›” **Suppression Files** โ€” `.forge-guard-suppressions` hides accepted risks and known false positives (`--suppressions`, `--show-suppressed`, `--generate-suppressions`)
- ๐Ÿ“ˆ **Historical Trend Tracking** โ€” opt-in SQLite history database (`~/.forge-guard/history.db`); `report --history` shows score trends over time, `report --regression` highlights findings new since the last audit
- ๐Ÿ“Š **Dashboard Mode** โ€” `forge-guard dashboard` serves a local web dashboard (`http://127.0.0.1:9090`) of the last audit with score gauges, severity charts, a score-over-time trend chart from the history DB, interactive filtering, and WebSocket auto-refresh (including `--watch` re-audit on file changes)

---

## Milestone Summary

All 15 development milestones are complete, and M16's Parallel Chain Auditing, Historical Trend Tracking, and Dashboard Mode are shipped. Here's what each delivered:

| # | Milestone | Key Deliverables |
|---|-----------|------------------|
| ๐Ÿ—๏ธ | **M1 โ€” Core Architecture** | Cargo project, error handling, config system, module structure |
| ๐ŸŽฎ | **M2 โ€” CLI Framework** | 18 subcommands via clap, global flags (`--json`, `--strict`, `--offline`, etc.) |
| ๐Ÿ”’ | **M3 โ€” Security Engine** | 50+ vulnerability checks across 5 severity levels, 11-category scoring system |
| ๐Ÿ”Œ | **M4 โ€” Plugin Architecture** | Plugin trait, built-in + IPC subprocess plugins, lifecycle management |
| โ›“๏ธ | **M5 โ€” Multi-Chain** | 17 EVM chains, alias resolution, chain registry with RPC testing |
| ๐Ÿ“Š | **M6 โ€” Report Engine** | Terminal (color-coded), JSON, and Markdown reports with findings & scores |
| ๐Ÿ›ก๏ธ | **M7 โ€” Deployment Guard** | Pre-deployment check pipeline, `deploy-safe` (non-bypassable), MEV detection |
| ๐Ÿ’ฅ | **M8 โ€” Exploit Engine** | Attack vector generation from findings, storage collision analysis |
| โœ… | **M9 โ€” Contract Verification** | 17-chain explorer registry, `forge verify-contract`, RPC bytecode match, auto-verify |
| ๐Ÿ”ง | **M10 โ€” Gas/Deps/Fuzz/CI** | Gas analysis, 30-entry vulnerability DB, fuzzing adapter, 4-platform CI templates |
| ๐Ÿค– | **M11 โ€” AI Auditing** | OpenAI, Claude, Ollama providers, consensus engine, structured Solidity prompts |
| ๐Ÿงช | **M12 โ€” Testing & Docs** | 850+ tests, comprehensive README, CONTRIBUTING.md, CI workflows |
| โšก | **M13 โ€” Post-MVP Polish** | Quick mode (~5x faster), executive summary, incremental file analysis, `--summary` flag |
| ๐ŸŽฏ | **M14 โ€” Developer Experience** | Applied audit templates (ERC20, ERC721, DeFi, Bridge, Upgradeable) with check/scoring/gates, SBOM `--ci` workflow export, per-file pre-commit hook, real `foundry.toml` sync, custom user templates |
| ๐Ÿ”— | **M15 โ€” External Tooling & Interop** | Slither/Mythril/Semgrep import with severity mapping + dedup + unified reports, Slack/Discord webhook notifications (`notify`, `--notify`), suppression files for accepted risks |
| โšก | **M16 โ€” Performance & Visualization** | Parallel chain auditing: `--all-chains` audits all 17 chains concurrently via Rayon, `--max-parallel-chains` concurrency bound, aggregated report with chain-labeled findings; historical trend tracking: opt-in SQLite history, `report --history` trends, `report --regression` new-finding diff; dashboard mode: local HTTP server with score gauges, severity charts, interactive filtering, and WebSocket live updates |

Detailed breakdown: [milestone-based-roadmap.md](milestone-based-roadmap.md)

---

## Installation

### Prerequisites

- **Rust** 1.85+ โ€” [Install]https://www.rust-lang.org/tools/install
- **Foundry** โ€” [Install]https://book.getfoundry.sh/getting-started/installation

### Option 1: Install via Cargo

```bash
cargo install forge-guard
```

### Option 2: Docker (pre-configured with Foundry)

Multi-arch image (`linux/amd64` + `linux/arm64`) published to GitHub Container Registry on every release โ€” no Rust or Foundry install needed:

```bash
docker pull ghcr.io/codetibo/forge-guard:latest

# Audit your project from a container (mount the project at /workspace)
docker run --rm -v "$PWD":/workspace ghcr.io/codetibo/forge-guard audit

# Full run with a custom working directory
docker run --rm -v "$PWD":/workspace -w /workspace ghcr.io/codetibo/forge-guard audit --full

# The image also ships forge, cast, anvil, and chisel
# (e.g. docker run --rm --entrypoint forge ghcr.io/codetibo/forge-guard --version)
```

### Option 3: Homebrew (macOS & Linux)

Formula auto-generated by [cargo-dist](https://opensource.axo.dev/cargo-dist/) on every release and published to the [codetibo/homebrew-tap](https://github.com/codetibo/homebrew-tap) tap:

```bash
brew install codetibo/tap/forge-guard
# or, once the tap is added:
brew tap codetibo/tap
brew install forge-guard
```

### Option 4: Add to PATH & Verify

```bash
# The forge-guard binary is installed to ~/.cargo/bin/
# Add to your .bashrc or .zshrc if not already in PATH:
export PATH="$HOME/.cargo/bin:$PATH"
```

### Verify Installation

```bash
forge-guard --version
forge-guard audit --help
```

---

## Quick Start

Navigate to a Foundry project and run:

```bash
cd my-foundry-project

# Run a comprehensive security audit
forge-guard audit

# Audit with strict mode (fail on any finding)
forge-guard audit --strict

# Full audit including exploit paths and gas analysis
forge-guard audit --full

# Check deployment readiness
forge-guard audit --production

# Generate Markdown report
forge-guard audit --markdown --report
```

### Example Output

```
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
           FORGE GUARD โ€” SECURITY REPORT       
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ“‹ Project:  .
โ›“๏ธ  Chain:    ethereum
๐Ÿ• Duration:  0.00s
๐Ÿ“ Files:     1

โ”€โ”€ Findings โ”€โ”€
  ๐Ÿ›‘ Critical:  0
  ๐Ÿ”ด High:     0
  ๐ŸŸก Medium:   0
  ๐Ÿ”ต Low:      0
  โšช Info:     0

โ”€โ”€ Scores โ”€โ”€
  ๐Ÿ” Access Control:       100/100
  ๐Ÿ›ก๏ธ  Security:            100/100
  ๐ŸŽฏ Fuzzing:             100/100
  โ›ฝ Gas:                  100/100
  ๐Ÿ—๏ธ  Architecture:        100/100
  โฌ†๏ธ  Upgradeability:     100/100

Overall Score: 100
Risk Level: MINIMAL
Production Ready: โœ… YES
Deployment: โœ… APPROVED
```

---

## All Commands

| Command | Description | Example |
|---------|-------------|---------|
| `forge-guard audit` | Run security audit with 50+ checks | `forge-guard audit --full --chain base` |
| `forge-guard audit --quick` | Quick audit (skips parser-heavy checks) | `forge-guard audit --quick` |
| `forge-guard audit --summary` | Executive summary report | `forge-guard audit --summary` |
| `forge-guard deploy` | Deploy with security guard | `forge-guard deploy --force` |
| `forge-guard deploy-safe` | Deploy with mandatory security pass | `forge-guard deploy-safe Counter` |
| `forge-guard fuzz` | Run fuzzing campaigns | `forge-guard fuzz --runs 50000` |
| `forge-guard invariant` | Run invariant tests | `forge-guard invariant --runs 2000` |
| `forge-guard simulate` | Deployment simulation | `forge-guard simulate --blocks 200` |
| `forge-guard gas` | Gas usage analysis | `forge-guard gas --all` |
| `forge-guard report` | Generate audit reports | `forge-guard report --format markdown` |
| `forge-guard report --history` | Show score trends over time from the SQLite history DB | `forge-guard report --history` |
| `forge-guard report --regression` | Highlight findings new since the last audit | `forge-guard report --regression` |
| `forge-guard dashboard` | Launch a local web dashboard of the last audit | `forge-guard dashboard --port 9090` |
| `forge-guard verify` | Verify contract deployments | `forge-guard verify --all` |
| `forge-guard doctor` | Project health analysis | `forge-guard doctor --fix` |
| `forge-guard watch` | Watch for changes and re-audit | `forge-guard watch --dirs src` |
| `forge-guard ci` | Generate CI/CD configs | `forge-guard ci --platform github` |
| `forge-guard benchmark` | Performance benchmarks | `forge-guard benchmark --iterations 50` |
| `forge-guard scan` | Dependency vulnerability scan | `forge-guard scan --update` |
| `forge-guard upgrade-check` | Upgrade path analysis | `forge-guard upgrade-check --all` |
| `forge-guard plugins` | Manage plugins | `forge-guard plugins list` |
| `forge-guard chain` | Chain configuration | `forge-guard chain list` |
| `forge-guard security` | Security configuration | `forge-guard security list` |
| `forge-guard sbom` | Generate Software Bill of Materials | `forge-guard sbom --format cyclonedx` |
| `forge-guard install-hook` | Install git pre-commit hook | `forge-guard install-hook` |
| `forge-guard import` | Import external analyzer findings (Slither, Mythril, Semgrep) | `forge-guard import --from slither results.json` |
| `forge-guard notify` | Send webhook notifications (Slack, Discord) | `forge-guard notify --findings reports/audit.json --on-critical` |

> ๐Ÿ“– **Full command reference**: See [COMMANDS.md]COMMANDS.md for detailed documentation of every subcommand, flag, and example.

### Common Flags

```bash
--chain <NAME>     # Target chain (default: ethereum)
--json             # JSON output
--markdown         # Markdown output
--html             # HTML output
--strict           # Fail on any MEDIUM+ finding
--offline          # Skip RPC calls
--production       # Production mode (extra checks)
--report           # Generate report files
--project-root <PATH> # Project root path (default: .)
```

---

## Detailed Usage Examples

### Security Audit

```bash
# Standard audit
forge-guard audit

# Full audit with everything
forge-guard audit --full

# Cross-chain audit
forge-guard audit --chain arbitrum
forge-guard audit --chain base --chain polygon
forge-guard audit --all-chains
forge-guard audit --all-chains --max-parallel-chains 2   # bound concurrent chain audits

# Output formats
forge-guard audit --json
forge-guard audit --markdown
forge-guard audit --json --report   # Save to file

# Analysis scope
forge-guard audit --strict           # Fail on any MEDIUM+ finding
forge-guard audit --production       # Production readiness check
forge-guard audit --offline          # Skip network calls
forge-guard audit --exploit          # Include exploit path generation
forge-guard audit --gas              # Include gas analysis
forge-guard audit --enable-history   # Record the audit in the SQLite history database

# Historical trend tracking (after running audit --enable-history)
forge-guard report --history        # Score trends over time
forge-guard report --regression     # Findings new since the last audit

# Dashboard mode โ€” visual dashboard of the last audit
forge-guard dashboard               # http://127.0.0.1:9090
forge-guard dashboard --port 8080   # Custom port
forge-guard dashboard --watch       # Re-audit on file changes + live WebSocket updates
forge-guard dashboard --open        # Open in the default browser
# The Score Trend panel charts audits recorded with --enable-history

# Audit templates
forge-guard audit --template erc20   # ERC20-focused audit
forge-guard audit --template defi    # DeFi-focused audit
forge-guard audit --list-templates   # List all available templates
```

### Deployment Guard

```bash
# Safe deploy (blocked by issues)
forge-guard deploy

# Deploy with bypass (warnings still shown)
forge-guard deploy --force

# Deploy specific contract
forge-guard deploy MyContract

# Mandatory security pass (no bypass)
forge-guard deploy-safe MyContract

# Create2 deployment
forge-guard deploy --salt 0xabc...

# Deploy with auto-verification
forge-guard deploy MyContract --verify --api-key YOUR_ETHERSCAN_KEY
```

### Contract Verification

```bash
# Verify a single contract
forge-guard verify --address 0x... --name MyContract

# Bulk verify all deployments from forge script
forge-guard verify --all

# Verify on a specific chain
forge-guard verify --address 0x... --name MyContract --chain base

# Explorer and bytecode match are attempted automatically
```

### Quick Mode & Executive Summary

```bash
# Quick audit โ€” skip parser-heavy checks for ~5x faster results
forge-guard audit --quick

# Show executive summary (concise PASS/FAIL verdict with action items)
forge-guard audit --summary

# Combine both for fastest feedback loop
forge-guard audit --quick --summary

# Still get the full report with --report
forge-guard audit --quick --report
```

### AI-Powered Auditing

```bash
# Run audit with AI (uses OPENAI_API_KEY env var)
forge-guard audit --ai

# Use Claude instead
forge-guard audit --ai --ai-provider claude --ai-model claude-5-sonnet-20260701

# Full AI audit (security + gas + logic auditors)
forge-guard audit --ai --ai-full

# Use local Ollama
forge-guard audit --ai --ai-provider ollama --ai-model llama3
```

### Deployment Simulation

```bash
# Run deployment simulation
forge-guard simulate

# With MEV analysis
forge-guard simulate --mev

# Custom block range and deployer
forge-guard simulate --blocks 200 --deployer 0x...
```

### Dependency Scanning

```bash
# Scan project dependencies
forge-guard scan

# Deep scan (include indirect dependencies)
forge-guard scan --depth 2

# Update vulnerability database
forge-guard scan --update

# JSON output
forge-guard scan --json

# Fail fast on critical vulnerabilities
forge-guard scan --fail-fast
```

### Project Health

```bash
# Full health check
forge-guard doctor

# Verbose output
forge-guard doctor --verbose

# Auto-fix issues
forge-guard doctor --fix

# Check specific category
forge-guard doctor --check dependencies

# Sync config from foundry.toml
forge-guard doctor --sync

# Preview sync changes without writing
forge-guard doctor --sync --dry-run

# Show diff of sync changes
forge-guard doctor --sync --diff
```

### Plugin Management

```bash
# List installed plugins
forge-guard plugins list

# Create a new plugin scaffold
forge-guard plugins new my-custom-check

# Install from source
forge-guard plugins install my-check https://github.com/user/my-check.git

# Enable/disable
forge-guard plugins enable my-custom-check
forge-guard plugins disable my-custom-check

# Remove
forge-guard plugins remove my-custom-check
```

### CI/CD Generation

```bash
# GitHub Actions
forge-guard ci --platform github

# GitLab CI
forge-guard ci --platform gitlab

# With deployment pipeline
forge-guard ci --platform github --include-deploy

# Custom output directory
forge-guard ci --output .github/workflows

# Overwrite existing configs
forge-guard ci --overwrite
```

### Git Pre-Commit Hook

Automatically audit staged `.sol` files before each commit. Blocks commits with HIGH/CRITICAL findings.

```bash
# Install pre-commit hook
forge-guard install-hook

# Force overwrite existing hook
forge-guard install-hook --force

# Uninstall the hook
forge-guard install-hook --uninstall

# Install in specific project
forge-guard install-hook --project /path/to/project
```

Bypass the hook temporarily:
```bash
FORGE_GUARD_SKIP_HOOK=1 git commit -m "urgent fix"
```

### SBOM Generation

Generate a CycloneDX 1.6 or SPDX 2.3 Software Bill of Materials for your Foundry project.

```bash
# Generate CycloneDX SBOM (stdout)
forge-guard sbom

# SPDX format
forge-guard sbom --format spdx

# Save to file
forge-guard sbom --output sbom.json

# Also write a GitHub Actions workflow for automated SBOM publishing
forge-guard sbom --ci
```

The `--ci` flag writes `.github/workflows/sbom.yml`, a workflow that generates both CycloneDX and SPDX SBOMs on every push to `main`/`master` and uploads them as build artifacts โ€” useful for supply-chain compliance (EO 14028 / NTIA minimum elements).

### External Analyzer Import

Adopt Forge Guard incrementally by importing findings from the tools you already run:

```bash
# Import Slither results
forge-guard import --from slither slither_results.json

# Import Mythril results and deduplicate against your last forge-guard audit
forge-guard import --from mythril mythril_out.json --findings reports/audit.json

# Import Semgrep results as a unified JSON report
forge-guard import --from semgrep semgrep_results.json --json --output unified.json
```

Severity scales are mapped automatically (Slither `impact`, Mythril `severity`/`type`, Semgrep `ERROR`/`WARNING`/`INFO`), and findings that duplicate Forge Guard's own are removed.

### Webhook Notifications

Get Slack/Discord alerts without watching the CI tab:

```bash
# Summarize the last audit to a Slack webhook
forge-guard notify --findings reports/audit.json --webhook https://hooks.slack.com/services/T/B/X

# Discord embed, only when critical findings exist
forge-guard notify --findings reports/audit.json --on-critical

# Preview the exact payload without sending
forge-guard notify --findings reports/audit.json --dry-run

# Notify automatically after an audit / deployment
forge-guard audit --notify
forge-guard deploy --notify
forge-guard deploy-safe --notify
```

Configure webhooks once in `forge-guard.toml` (see [Configuration](#configuration)); blocked deployments always notify, successful runs respect `min_severity`.

### Suppression Files

Permanently silence known false positives and accepted risks (see [`examples/.forge-guard-suppressions`](examples/.forge-guard-suppressions) for the file format):

```bash
# Generate a suppression file from the current findings
forge-guard audit --generate-suppressions

# Use it on subsequent audits (matching findings are hidden from scoring)
forge-guard audit --suppressions .forge-guard-suppressions

# Show suppressed findings (visually marked) instead of hiding them
forge-guard audit --suppressions .forge-guard-suppressions --show-suppressed
```

File format โ€” one entry per line, `FINDING_ID [file] # comment`:

```text
FA-H-001 # Known false positive in Vault.sol
FA-M-004 src/oracle/PriceFeed.sol
```

### Audit Templates

Use predefined audit templates to focus on specific contract types. Templates don't just print a banner โ€” they **actually adjust the audit**: template `enabled_checks`/`disabled_checks` are wired into the security engine, `focus_areas` weight categories 2ร— in the overall score, and `min_scores` gate production readiness.

```bash
# List available templates
forge-guard audit --list-templates

# ERC20 token audit
forge-guard audit --template erc20

# DeFi protocol audit
forge-guard audit --template defi

# Upgradeable contract audit
forge-guard audit --template upgradeable
```

#### Built-in Templates

| Template | Focus |
|----------|-------|
| `erc20` | Approval bugs, permit replay, token-specific vulnerabilities |
| `erc721` | NFT patterns, royalties, metadata integrity |
| `defi` | Lending, AMM, oracles, flash loans, MEV resistance |
| `bridge` | Cross-chain messaging, validator sets, replay attacks |
| `upgradeable` | Proxy patterns, storage layouts, initializers |

#### Custom Templates

Drop a JSON file into `~/.forge-guard/templates/` to define your own template or **override a built-in by name**:

```json
{
  "name": "my-protocol",
  "description": "My protocol's audit profile",
  "enabled_checks": ["FA-H-011", "FA-H-016"],
  "disabled_checks": ["FA-L-001"],
  "min_scores": { "exploit_resistance": 85 },
  "focus_areas": ["exploit_resistance", "security"]
}
```

Run it with `forge-guard audit --template my-protocol`.

---

## Configuration

Forge Guard reads configuration from `forge-guard.toml` in the project root. All fields are optional.

> ๐Ÿ’ก **Ready-to-edit templates:** see [`examples/forge-guard.toml`]examples/forge-guard.toml for a fully commented config (including Slack/Discord webhooks) and [`examples/.forge-guard-suppressions`]examples/.forge-guard-suppressions for a sample suppression file.

### Minimal Configuration

```toml
# forge-guard.toml
src_dirs = ["src", "contracts"]
```

### Full Configuration Reference

```toml
# โ”€โ”€ Source Settings โ”€โ”€
src_dirs = ["src", "contracts"]           # Source directories to scan
exclude = ["test", "mock", "interfaces"]  # Exclusion patterns

# โ”€โ”€ Chain โ”€โ”€
chain = "ethereum"                        # Default target chain

# โ”€โ”€ Security Engine โ”€โ”€
[security]
enable_high = true                        # Enable HIGH severity checks
enable_medium = true                      # Enable MEDIUM severity checks
enable_low = true                         # Enable LOW severity checks
enable_info = false                       # Enable INFORMATIONAL checks
exploit_analysis = true                   # Enable exploit path analysis
gas_analysis = false                      # Enable gas analysis
max_findings_per_check = 50               # Max findings per check type

# โ”€โ”€ Deployment Guard โ”€โ”€
[deployment]
min_score = 70                            # Minimum score to deploy (0-100)
block_on_critical = true                  # Block on critical findings
block_on_high = true                      # Block on high findings
block_on_medium = false                   # Block on medium findings
require_fuzzing = true                    # Require fuzzing to pass
require_invariants = true                 # Require invariants to pass
simulate_deployment = true                # Run deployment simulation
require_verification = false              # Require on-chain verification
auto_verify = false                       # Auto-verify after deployment
explorer_api_key = null                   # Explorer API key (reads env var when null)

# โ”€โ”€ Report Settings โ”€โ”€
[report]
include_snippets = true                   # Include code snippets
include_exploit_paths = true              # Include exploit demonstrations
include_recommendations = true            # Include fix recommendations
output_dir = "reports"                    # Report output directory

# โ”€โ”€ Caching โ”€โ”€
[cache]
enabled = false                           # Enable caching (disable for CI)
directory = ".forge-guard-cache"          # Cache directory
max_size_mb = 500                         # Maximum cache size
ttl_seconds = 3600                        # Cache TTL (1 hour)

# โ”€โ”€ Historical Trend Tracking โ”€โ”€
[history]
enabled = false                           # Persist audits to SQLite (opt-in)
db_path = "~/.forge-guard/history.db"    # Optional DB path override (~ is expanded)

# โ”€โ”€ Plugin Configuration โ”€โ”€
[plugins]
directories = [".forge-guard/plugins"]    # Plugin search paths
disabled = ["forge-guard-example"]        # Disable specific plugins
allow_external = false                    # Allow external plugin loading

# โ”€โ”€ AI Auditors โ”€โ”€
[ai]
provider = "openai"                       # AI provider: openai, claude, ollama
model = "gpt-5"                            # Model identifier
temperature = 0.1                         # Sampling temperature (0.0-1.0)
max_tokens = 4000                         # Max tokens per response
min_confidence = 0.5                      # Minimum confidence (0.0-1.0)
full_audit = false                        # Run all auditors (security + gas + logic)

# โ”€โ”€ Webhook Notifications โ”€โ”€
[notifications.slack]
webhook = "https://hooks.slack.com/services/T000/B000/XXXX"  # Slack incoming webhook
min_severity = "high"                    # Notify when findings are at least this severe

[notifications.discord]
webhook = "https://discord.com/api/webhooks/123/abc"         # Discord webhook
min_severity = "critical"
```

### Command-Line Overrides

CLI flags override config file values:

```bash
forge-guard audit --strict         # Overrides security config
forge-guard audit --chain base     # Overrides default chain
forge-guard audit --offline        # Skips RPC
```

---

## Architecture

```
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚   CLI Layer  โ”‚  (clap argument parsing)
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ            โ–ผ            โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚  Audit   โ”‚ โ”‚  Deploy  โ”‚ โ”‚   CI     โ”‚  ... 18 commands
       โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚             โ”‚            โ”‚
            โ–ผ             โ–ผ            โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚           Security Engine            โ”‚
       โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
       โ”‚  โ”‚CEI   โ”‚ โ”‚Accessโ”‚ โ”‚Delegatecall โ”‚  โ”‚ 50+ checks
       โ”‚  โ”‚Analysisโ”‚ โ”‚Controlโ”‚โ”‚             โ”‚  โ”‚
       โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ                   โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚Plugin Registryโ”‚ โ”‚  Chain Registry   โ”‚
       โ”‚ Built-in/IPC  โ”‚ โ”‚  17 EVM Chains    โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ                   โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚Deployment    โ”‚ โ”‚  Report Engine    โ”‚
       โ”‚Guard         โ”‚ โ”‚  JSON / Markdown  โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ                   โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚  Exploit     โ”‚ โ”‚  Doctor / Scan   โ”‚
       โ”‚  Engine      โ”‚ โ”‚  Health Checks   โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

### Module Breakdown

| Module | Purpose |
|--------|---------|
| `src/core/` | Types, config, error handling, audit results |
| `src/security/` | 50+ vulnerability checks + scoring engine |
| `src/plugins/` | Plugin trait, built-in + external (IPC) plugins |
| `src/chains/` | Chain registry with 17 EVM chains |
| `src/deployment/` | Deployment guard + on-chain contract verifier |
| `src/deployment/verifier/` | Block explorer registry, forge verify, RPC bytecode match |
| `src/reports/` | JSON and Markdown report generation |
| `src/exploit/` | Attack vector and exploit path generation |
| `src/dependencies/` | 30+ known vulnerability entries, online updates |
| `src/doctor/` | Project health analysis |
| `src/gas/` | Gas usage analysis and optimization suggestions |
| `src/fuzzing/` | Fuzzing adapter interface |
| `src/ci/` | CI/CD pipeline template generation |
| `src/benchmark/` | Performance benchmarking |
| `src/parser/` | Solidity source code parser |
| `src/ai/` | AI auditing: providers (OpenAI, Claude, Ollama), auditors, consensus engine |
| `src/ai/providers/` | OpenAI, Claude, Ollama HTTP client implementations |
| `src/ai/auditors/` | Security, Gas, Logic auditor agents with Solidity prompts |
| `src/ai/consensus/` | Cross-provider validation with confidence boosting |
| `src/importer/` | External analyzer import: Slither/Mythril/Semgrep parsers, severity mapping, dedup |
| `src/notify/` | Slack/Discord webhook payloads and sender, severity gating |
| `src/suppressions/` | Suppression file parsing, matching, and generation |
| `src/history/` | SQLite history database, score trends, regression diffing |
| `src/dashboard/` | Local HTTP dashboard (axum): score gauges, severity charts, WebSocket live updates |
| `src/utils/` | Caching, formatting utilities |

---

## Security Checks

### HIGH Severity (blocks deployment)

| ID | Check | Description |
|----|-------|-------------|
| FA-H-001 | Reentrancy | CEI violations, callback reentrancy, read-only reentrancy, self-call paths |
| FA-H-002 | Access Control | Missing modifiers, inline access checks, role-based access in initialize functions |
| FA-H-003 | Delegatecall | Unsafe delegatecall patterns |
| FA-H-004 | tx.origin | tx.origin for authentication |
| FA-H-005 | CREATE2 | CREATE2 address precomputation risks |
| FA-H-006 | DoS | Unbounded loops, denial of service |
| FA-H-007 | Storage Collision | Upgradeable contract storage gaps |
| FA-H-008 | Unsafe Assembly | Inline assembly blocks |
| FA-H-009 | Selfdestruct | selfdestruct usage |
| FA-H-010 | Proxy Vulnerabilities | Unsafe proxy patterns |
| FA-H-011 | Oracle Manipulation | Price oracle manipulation risks |
| FA-H-012 | Signature Vulnerabilities | Signature malleability, EIP-2098 issues |
| FA-H-013 | Replay Attacks | Cross-chain replay, missing nonces |
| FA-H-014 | ERC20 Issues | Approve race conditions |
| FA-H-015 | Bridge Vulnerabilities | Cross-chain bridge patterns |
| FA-H-016 | Flash Loan Issues | Flash loan attack surface |
| FA-H-017 | MEV Issues | Slippage, sandwich vulnerabilities |
| FA-H-018 | Cross-Chain Issues | Chain ID handling, message verification |
| FA-H-019 | Dependency Vulnerabilities | Known vulnerable dependencies |
| FA-H-020 | Unsafe Imports | HTTP/github imports |
| FA-H-021 | Unsafe Initializers | Missing initializer modifiers |
| FA-H-022 | Unsafe Upgrade Paths | UUPS/Transparent proxy paths |
| FA-H-023 | Clone Vulnerabilities | Minimal proxy clones |

### MEDIUM Severity

| ID | Check | Description |
|----|-------|-------------|
| FA-M-001 | Gas Problems | Inefficient patterns |
| FA-M-002 | Unsafe Casting | Unsafe type conversions |
| FA-M-003 | Timestamp Manipulation | block.timestamp in critical logic |
| FA-M-004 | Storage Inefficiencies | Unpacked storage variables |
| FA-M-005 | Unsafe Events | Sensitive data in events |
| FA-M-006 | Poor Visibility | Public mappings |
| FA-M-007 | Bad Modifiers | Modifiers making external calls |
| FA-M-008 | Unsafe Math | Unchecked arithmetic |
| FA-M-009 | Poor Access Patterns | Storage vs memory |

### LOW & INFORMATIONAL

- Naming conventions
- Code duplication
- Optimization suggestions
- Style issues
- Missing documentation
- Line length

---

## Plugin Development

### Built-in Plugin

Create a built-in plugin by implementing the `Plugin` trait:

```rust
use forge_guard::plugins::{Plugin, PluginContext, PluginResult};

pub struct MyCustomCheck;

impl Plugin for MyCustomCheck {
    fn name(&self) -> &'static str { "my-custom-check" }
    fn version(&self) -> &'static str { "0.1.0" }
    fn description(&self) -> &'static str { "My custom security check" }

    fn execute(&self, ctx: &PluginContext) -> PluginResult {
        // Your analysis logic here
        // ctx.source_files contains the Solidity files to analyze
        // ctx.config has the project configuration
        Ok(Vec::new()) // Return findings
    }
}
```

### External Plugin (IPC Subprocess)

Plugins can also be external binaries communicating via JSON IPC:

```bash
# Create a plugin scaffold
forge plugins new my-external-check
cd .forge-guard/plugins/my-external-check
cargo build --release
forge plugins list
```

The protocol:
- **stdin**: JSON `PluginIpcInput` with context
- **stdout**: JSON `PluginIpcOutput` with findings
- **stderr**: Diagnostic logs

---

## CI/CD Integration

### GitHub Actions (auto-generated)

```yaml
# Run: forge-guard ci --platform github
name: Forge Guard Security Check
on: [push, pull_request]
jobs:
  security-audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - uses: foundry-rs/foundry-toolchain@v1
        with:
          version: nightly
      - name: Install Forge Guard
        run: cargo install forge-guard
      - name: Security Audit
        run: forge-guard audit --strict
      - name: Scan Dependencies
        run: forge-guard scan --depth 1
      - name: Generate Report
        run: forge-guard audit --report --markdown
```

### With Deployment Protection

```yaml
name: Deploy
on:
  push:
    branches: [main]
jobs:
  security-audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: foundry-rs/foundry-toolchain@v1
      - name: Security check
        run: forge-guard audit --strict --production
      - name: Safe deploy
        run: forge-guard deploy-safe
        env:
          ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
          PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
```

---

## Performance

- **Parallel execution** via Rayon โ€” all file analysis runs in parallel across CPU cores
- **Filesystem caching** โ€” analysis results cached with TTL; only changed files re-analyzed
- **Memory-efficient** โ€” streaming reads for large codebases
- **Incremental** โ€” re-audits only process modified files
- **Benchmark mode** โ€” measure and compare performance across versions

```bash
# Run benchmarks
forge-guard benchmark --iterations 50

# Benchmark specific module
forge-guard benchmark --module source_discovery

# Compare with baseline
forge-guard benchmark --compare baseline.json
```

---

## Development

### Building

```bash
git clone https://github.com/codetibo/forge-guard.git
cd forge-guard
cargo build
cargo build --release    # Production build
# The binary is at target/release/forge-guard
```

### Testing

```bash
# Run all tests (850+)
cargo test

# Run specific test suites
cargo test --lib              # Unit tests
cargo test --test cli_tests   # CLI & end-to-end binary tests
cargo test --test mod         # Integration tests
cargo test --lib dependencies # Dependency scanner tests
cargo test --lib plugins      # Plugin tests

# Run with output
cargo test -- --nocapture
```

### Linting & Formatting

```bash
# Check formatting
cargo fmt --check

# Apply formatting
cargo fmt

# Lint
cargo clippy -- -D warnings
```

### Test Coverage

| Module | Tests | Status |
|--------|-------|--------|
| AI providers (OpenAI, Claude, Ollama) | โœ… 11 | in-module tests |
| AI auditors (prompts, parsing, chunking) | โœ… 12 | in-module tests |
| AI consensus (dedup, boost, filtering) | โœ… 9 | in-module tests |
| Contract verifier (explorer URLs, bytecode) | โœ… 11 | in-module tests |
| Core types/config | โœ… 13 | integration_tests |
| Security engine (incl. template filtering) | โœ… 34 | security_tests |
| CLI end-to-end (audit, deploy, templates, sync, SBOM, hook) | โœ… 104 | cli_tests |
| Plugin architecture | โœ… 25 | plugin_tests |
| Dependency scanner | โœ… 14 | in-module tests |
| Parser | โœ… 39 | in-module tests |
| Chains | โœ… 8 | in-module tests |
| Deployment | โœ… 6 | in-module tests |
| Reports | โœ… 3 | in-module tests |
| Exploit engine | โœ… 2 | in-module tests |
| Utils | โœ… 6 | in-module tests |
| Gas analysis | โœ… 3 | in-module tests |
| CI generator (incl. SBOM workflow) | โœ… 21 | in-module tests |
| Doctor (incl. foundry.toml sync) | โœ… 18 | in-module tests |
| SBOM formats (CycloneDX/SPDX) | โœ… 56 | in-module tests |
| Templates (apply, override, serialization) | โœ… 16 | in-module tests |
| Pre-commit hook (install/uninstall/script) | โœ… 13 | in-module tests |

---

## Supported Chains

| Chain | Chain ID | Currency | Status |
|-------|----------|----------|--------|
| Ethereum | 1 | ETH | โœ… |
| Base | 8453 | ETH | โœ… |
| Arbitrum | 42161 | ETH | โœ… |
| Optimism | 10 | ETH | โœ… |
| Polygon | 137 | MATIC | โœ… |
| BNB Chain | 56 | BNB | โœ… |
| Avalanche | 43114 | AVAX | โœ… |
| Scroll | 534352 | ETH | โœ… |
| Linea | 59144 | ETH | โœ… |
| Unichain | 130 | ETH | โœ… |
| ZKSync | 324 | ETH | โœ… |
| HyperEVM | 999 | HYPE | โœ… |
| Monad | 10143 | MON | โœ… |
| Sonic | 146 | S | โœ… |
| Blast | 81457 | ETH | โœ… |
| Mantle | 5000 | MNT | โœ… |
| Robinhood | 31753 | ETH | โœ… |

### Future Support
Solana ยท Tron ยท Sui ยท Aptos

---

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.

Key points:
- Run `cargo test && cargo fmt && cargo clippy` before submitting PRs
- Add tests for new functionality
- Document public APIs
- Follow Rust standard conventions

---

## License

MIT โ€” see [LICENSE](LICENSE) for details.

---

## Roadmap

See [milestone-based-roadmap.md](milestone-based-roadmap.md) for the complete development roadmap.

| Milestone | Status |
|-----------|--------|
| M1: Core Architecture | โœ… Complete |
| M2: CLI Framework | โœ… Complete |
| M3: Security Engine | โœ… Complete |
| M4: Plugin Architecture | โœ… Complete |
| M5: Multi-Chain Support | โœ… Complete |
| M6: Report Engine | โœ… Complete |
| M7: Deployment Guard | โœ… Complete |
| M8: Exploit Engine | โœ… Complete |
| M9: Contract Verification | โœ… Complete |
| M10: Gas/Deps/Fuzz/CI/Bench | โœ… Complete |
| M11: AI-Powered Auditing | โœ… Complete |
| M12: Testing & Documentation | โœ… Complete |
| M13: Post-MVP Polish | โœ… Complete |
| M14: Developer Experience & Integrations | โœ… Complete |
| M15: External Tooling & Interoperability | โœ… Complete |
| M16: Performance & Visualization | โœ… Complete โ€” Parallel Chain Auditing, Historical Trend Tracking, Dashboard Mode |
| M17: CI/CD & Platform Expansion | ๐Ÿ”„ In Progress โ€” Docker Image โœ… (ghcr.io multi-arch), Homebrew Tap โœ… (cargo-dist formula), VS Code config pending |