paladin-ai 0.5.1

Enterprise AI orchestration framework with multi-agent coordination patterns
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
# Paladin CLI Usage Guide

Complete guide to using the Paladin command-line interface for running AI agents and multi-agent battalions.

## Table of Contents

- [Quick Start]#quick-start
- [Installation]#installation
- [Environment Setup]#environment-setup
- [Getting Started]#getting-started
  - [paladin onboarding]#paladin-onboarding
  - [paladin setup-check]#paladin-setup-check
  - [paladin features]#paladin-features
- [Commands Reference]#commands-reference
  - [paladin agent]#paladin-agent
  - [paladin battalion]#paladin-battalion
  - [paladin muster]#paladin-muster
  - [paladin council]#paladin-council
  - [paladin maneuver]#paladin-maneuver
  - [paladin arsenal]#paladin-arsenal
- [Configuration Files]#configuration-files
- [Examples]#examples
- [Troubleshooting]#troubleshooting

> 📖 **For comprehensive configuration documentation**, see the [CLI Configuration Guide]cli-configuration.md - covers garrison (memory), arsenal (tools), and scheduler configuration with complete examples.

## Quick Start

```bash
# 1. Run the interactive onboarding wizard
paladin onboarding

# 2. Verify your setup
paladin setup-check

# 3. Discover available features
paladin features

# 4. Generate a battalion configuration using AI
paladin muster --task "Analyze market trends and generate a report"

# 5. Start a quick group discussion
paladin council --topic "Best practices for AI agent design"
```

## Quick Start (Manual Setup)

```bash
# 1. Set your API key
export OPENAI_API_KEY="sk-..."

# 2. Generate a Paladin template
paladin agent new -n my-agent -o my-agent.yaml

# 3. Edit the template (customize system_prompt, etc.)
vim my-agent.yaml

# 4. Run your Paladin
paladin agent run -c my-agent.yaml -i "Hello, Paladin!"
```

## Installation

```bash
# Build from source
cargo build --release --bin paladin-cli

# Binary will be at: target/release/paladin-cli

# Add to PATH (optional)
sudo ln -s $(pwd)/target/release/paladin-cli /usr/local/bin/paladin
```

## Environment Setup

### Required: API Keys

Set the appropriate environment variable for your chosen LLM provider:

```bash
# OpenAI
export OPENAI_API_KEY="sk-..."

# DeepSeek
export DEEPSEEK_API_KEY="sk-..."

# Anthropic
export ANTHROPIC_API_KEY="sk-..."
```

### Optional: MCP Servers

For external tool access (Arsenal), install MCP servers:

```bash
# Web search capability
pip install mcp-web-search

# Or use npx for Node-based servers
npx -y @modelcontextprotocol/server-filesystem /path/to/dir
```

---

## Getting Started

New to Paladin? Start here with these helpful commands.

### paladin onboarding

Interactive wizard to set up your Paladin environment.

**Syntax:**
```bash
paladin onboarding
```

**What it does:**
1. Welcomes you and explains Paladin capabilities
2. Guides you through provider selection (OpenAI, Anthropic, DeepSeek)
3. Validates your API keys with real connectivity tests
4. Creates/updates your `.env` file with secure configuration
5. Generates sample configuration files for quick start
6. Provides next steps and resources

**Examples:**
```bash
# Run the interactive onboarding wizard
paladin onboarding

# The wizard will guide you through:
# ✓ Provider selection
# ✓ API key input (with secure masking)
# ✓ Connectivity validation
# ✓ Environment file creation
# ✓ Sample config generation
```

**Features:**
- ✅ Secure API key input with masking
- ✅ Real-time validation with actual API calls
- ✅ Intelligent `.env` file merging (no duplicates)
- ✅ Resumable state (interruption-safe)
- ✅ Sample configuration generation

**See also:** [Onboarding Guide](cli-onboarding.md)

---

### paladin setup-check

Validate your Paladin installation and environment configuration.

**Syntax:**
```bash
paladin setup-check [OPTIONS]
```

**Options:**
- `-v, --verbose` - Show detailed version strings and response times
- `--quiet` - Minimal output, only show failures

**What it checks:**
1. **System**: Paladin CLI version, Rust toolchain version
2. **Environment**: .env file existence, API key configuration
3. **Providers**: OpenAI, Anthropic, DeepSeek connectivity
4. **Services** (optional): Redis, Qdrant availability

**Examples:**
```bash
# Basic check with summary
paladin setup-check

# Detailed check with timing information
paladin setup-check --verbose

# Quiet mode (CI-friendly)
paladin setup-check --quiet
```

**Exit codes:**
- `0` - All checks passed
- `1` - Critical failures detected
- `2` - Warnings present (non-critical)

**Sample output:**
```
=== Paladin Setup Check ===

System:
  ✓ Paladin CLI: v0.1.0
  ✓ Rust Toolchain: 1.75.0

Environment:
  ✓ .env file: Found
  ⚠ OPENAI_API_KEY: Configured but not validated

Providers:
  ✓ OpenAI: Connected (gpt-4, gpt-3.5-turbo) [342ms]
  ✗ Anthropic: API key not configured
  ⚠ DeepSeek: Connection timeout

Services (Optional):
  ✓ Redis: Connected
  - Qdrant: Not configured

=== Summary ===
✓ 5 passed
⚠ 2 warnings
✗ 1 failed

Next Steps:
  • Configure ANTHROPIC_API_KEY in .env
  • Check DeepSeek API endpoint connectivity
```

**See also:** [Setup Check Guide](cli-setup-check.md)

---

### paladin features

Discover available Paladin features and capabilities.

**Syntax:**
```bash
paladin features [OPTIONS]
```

**Options:**
- `-c, --category <CATEGORY>` - Filter by category
  - Valid values: `agent`, `battalion`, `orchestration`, `memory`, `utilities`
- `-f, --format <FORMAT>` - Output format (default: table)
  - Valid values: `table`, `json`

**Examples:**
```bash
# List all features
paladin features

# Show only battalion patterns
paladin features --category battalion

# Show orchestration patterns
paladin features --category orchestration

# JSON output for scripting
paladin features --format json
```

**Sample output:**
```
=== Paladin Features ===

Agent:
  • Basic Paladin         - Single autonomous AI agent
  • Autonomous Planning   - Self-directed task planning
  • Tool Integration      - External tool access via Arsenal

Battalion:
  • Formation            - Sequential agent execution
  • Phalanx              - Parallel agent execution
  • Campaign             - DAG-based workflow orchestration
  • Chain of Command     - Hierarchical delegation

Orchestration:
  • Conclave             - Expert panel discussions
  • Council              - Quick group discussions
  • Grove                - Dynamic routing patterns
  • Maneuver             - Flow-based orchestration

Memory:
  • In-Memory Garrison   - Fast, non-persistent memory
  • Persistent Garrison  - SQLite-backed memory
  • Sanctum (RAG)        - Vector-based retrieval

[24 features total]
```

**See also:** [Architecture Documentation](../architecture/overview.md)

---

## Commands Reference

### paladin agent

Manage and run individual Paladin agents.

#### `paladin agent new`

Generate a new Paladin configuration template.

**Syntax:**
```bash
paladin agent new -n <name> -o <output> [-p <provider>]
```

**Options:**
- `-n, --name <NAME>` - Paladin name (required)
- `-o, --output <PATH>` - Output file path (required)
- `-p, --provider <PROVIDER>` - LLM provider (optional, default: openai)
  - Valid values: `openai`, `deepseek`, `anthropic`

**Examples:**
```bash
# Basic template with OpenAI
paladin agent new -n MyAgent -o agent.yaml

# DeepSeek template
paladin agent new -n DeepAgent -o deepseek-agent.yaml -p deepseek

# Anthropic template
paladin agent new -n ClaudeAgent -o claude-agent.yaml -p anthropic
```

#### `paladin agent run`

Execute a Paladin from a configuration file.

**Syntax:**
```bash
paladin agent run -c <config> [-i <input>] [-o <output>] [-v]
```

**Options:**
- `-c, --config <PATH>` - Configuration file path (required)
- `-i, --input <TEXT>` - Input text (optional, prompts if omitted)
- `-o, --output <PATH>` - Save JSON output to file (optional)
- `-v, --verbose` - Show detailed execution logs (optional)

**Examples:**
```bash
# Run with command-line input
paladin agent run -c agent.yaml -i "What is Rust?"

# Interactive mode (prompts for input)
paladin agent run -c agent.yaml

# With verbose output
paladin agent run -c agent.yaml -i "Query" --verbose

# Save results to file
paladin agent run -c agent.yaml -i "Query" -o result.json
```

---

### paladin battalion

Manage and run multi-agent battalions.

#### `paladin battalion new`

Generate a new Battalion configuration template.

**Syntax:**
```bash
paladin battalion new -n <name> -t <type> -o <output>
```

**Options:**
- `-n, --name <NAME>` - Battalion name (required)
- `-t, --type <TYPE>` - Battalion type (required)
  - `formation` - Sequential execution (pipeline)
  - `phalanx` - Parallel execution (concurrent)
  - `campaign` - DAG workflow (complex dependencies)
  - `chain-of-command` - Hierarchical delegation
- `-o, --output <PATH>` - Output file path (required)

**Examples:**
```bash
# Formation (sequential)
paladin battalion new -n MyFormation -t formation -o formation.yaml

# Phalanx (parallel)
paladin battalion new -n MyPhalanx -t phalanx -o phalanx.yaml

# Campaign (DAG)
paladin battalion new -n MyCampaign -t campaign -o campaign.yaml

# Chain of Command (hierarchical)
paladin battalion new -n MyTeam -t chain-of-command -o team.yaml
```

#### `paladin battalion run`

Execute a Battalion from a configuration file.

**Syntax:**
```bash
paladin battalion run -c <config> [-i <input>] [-o <output>] [-v]
```

**Options:**
- `-c, --config <PATH>` - Configuration file path (required)
- `-i, --input <TEXT>` - Input text (optional, prompts if omitted)
- `-o, --output <PATH>` - Save JSON output to file (optional)
- `-v, --verbose` - Show detailed execution logs (optional)

**Examples:**
```bash
# Run formation
paladin battalion run -c formation.yaml -i "Process this text"

# Run phalanx with verbose output
paladin battalion run -c phalanx.yaml -i "Analyze this" --verbose

# Run campaign and save results
paladin battalion run -c campaign.yaml -i "Input" -o results.json
```

---

### paladin muster

Generate battalion configurations using AI-powered task analysis.

**Syntax:**
```bash
paladin muster [OPTIONS]
```

**Options:**
- `-t, --task <DESCRIPTION>` - Task description (prompts if omitted)
- `-o, --output <PATH>` - Output file path (default: muster_<name>_<timestamp>.yaml)
- `-p, --provider <PROVIDER>` - LLM provider for analysis (default: openai)
  - Valid values: `openai`, `deepseek`, `anthropic`
- `-m, --model <MODEL>` - Specific model to use (optional)
- `--no-review` - Skip interactive review (non-interactive mode)
- `--execute` - Run the generated battalion immediately (experimental)

**What it does:**
1. Analyzes your task description using LLM
2. Recommends appropriate battalion pattern (Formation, Phalanx, Campaign, etc.)
3. Generates agent roles and system prompts
4. Creates complete YAML configuration
5. Allows interactive review and editing
6. Saves configuration to file

**Examples:**
```bash
# Interactive mode (wizard)
paladin muster

# With task description
paladin muster --task "Analyze market trends and generate investment report"

# Custom output path
paladin muster --task "Code review workflow" -o code-review.yaml

# Non-interactive mode (for scripting)
paladin muster --task "Data pipeline" --no-review -o pipeline.yaml

# Use specific provider and model
paladin muster --task "Research summary" -p anthropic -m claude-3-opus
```

**Task Examples:**
```
"Research competitive landscape and create comparison report"
→ Recommends: Formation (researcher -> analyzer -> writer)

"Review pull request from multiple perspectives"
→ Recommends: Phalanx (code_quality, security, performance in parallel)

"Complex data processing with conditional steps"
→ Recommends: Campaign (DAG with dependencies)

"Multi-step decision making with oversight"
→ Recommends: Chain of Command (analysts -> supervisor)
```

**Fallback Mode:**
If LLM is unavailable, muster uses template-based fallback with keyword matching:
- Sequential keywords (then, after, next) → Formation
- Parallel keywords (multiple, compare, simultaneously) → Phalanx
- Discussion keywords (discuss, consensus, perspectives) → Council
- Default → Formation (safe fallback)

**See also:** [Muster Guide](cli-muster.md)

---

### paladin council

Start a quick multi-agent discussion on a topic.

**Syntax:**
```bash
paladin council [OPTIONS]
```

**Options:**
- `--topic <TOPIC>` - Discussion topic (prompts if omitted)
- `-p, --participants <COUNT>` - Number of participants (default: 3, min: 2, max: 10)
- `--roles <ROLES>` - Custom roles (comma-separated, overrides default assignment)
- `--max-rounds <COUNT>` - Maximum discussion rounds (default: 5)
- `--save <PATH>` - Save transcript to file (markdown format)
- `-m, --model <MODEL>` - LLM model to use (optional)
- `-t, --temperature <TEMP>` - LLM temperature (optional)

**Default Role Assignment:**
- 2 participants: Advocate, Critic
- 3 participants: + Moderator
- 4 participants: + Synthesizer
- 5 participants: + Subject Matter Expert
- 6+ participants: + Expert 2, Expert 3, etc.

**Examples:**
```bash
# Interactive mode (wizard)
paladin council

# With topic
paladin council --topic "Best practices for microservices architecture"

# Custom participant count
paladin council --topic "AI ethics" --participants 5

# Custom roles
paladin council --topic "Product roadmap" --roles "PM,Engineer,Designer,Customer"

# Save transcript
paladin council --topic "Security review" --save security-discussion.md

# Full configuration
paladin council \
  --topic "System design review" \
  --participants 4 \
  --max-rounds 3 \
  --model gpt-4 \
  --temperature 0.8 \
  --save design-review.md
```

**Sample Output:**
```
=== Council Discussion: Best Practices for Microservices ===

Participants: 3
Roles: Advocate, Critic, Moderator

──────────────────────────────────────────
Round 1
──────────────────────────────────────────

[Advocate] (Proponent):
Microservices offer excellent scalability and independent deployment...

[Critic] (Skeptic):
However, the operational complexity increases significantly...

[Moderator] (Facilitator):
Both perspectives raise valid points. Let's explore the trade-offs...

──────────────────────────────────────────
Round 2
──────────────────────────────────────────

[... discussion continues ...]

=== Summary ===

Rounds: 5
Total Contributions: 15

Key Points:
• Scalability benefits clear for large teams
• Operational overhead requires investment
• Event-driven patterns recommended

Consensus:
Start with monolith, extract services as needed

Conclusion:
The council recommends a pragmatic approach: begin with a well-structured
monolith and extract microservices only when clear boundaries emerge.
```

**Transcript Format** (when using --save):
```markdown
# Council Discussion: [Topic]

**Started:** 2026-02-09 10:30:00  
**Ended:** 2026-02-09 10:45:00  
**Participants:** 3

## Participants

- **Alice** - Advocate (Proponent)
- **Bob** - Critic (Skeptic)
- **Carol** - Moderator (Facilitator)

## Discussion

### Round 1

**Alice** (Advocate): [message]
**Bob** (Critic): [message]
**Carol** (Moderator): [message]

### Round 2

[... continues ...]

## Summary

[Summary content]
```

**See also:** [Council Guide](cli-council.md), [Conclave Documentation](council.md)

---

### paladin maneuver

Visualize and validate Flow DSL orchestration patterns.

#### `paladin maneuver visualize`

Generate visual representation of a Maneuver flow expression.

**Syntax:**
```bash
paladin maneuver visualize -c <config> [-f <format>] [-o <output>]
```

**Options:**
- `-c, --config <PATH>` - Path to Maneuver YAML configuration (required)
- `-f, --format <FORMAT>` - Output format (optional, default: ascii)
  - `ascii` - ASCII tree visualization for terminal
  - `mermaid` - Mermaid.js flowchart for documentation
- `-o, --output <PATH>` - Save output to file instead of stdout (optional)

**Examples:**
```bash
# ASCII tree visualization (terminal-friendly)
paladin maneuver visualize -c workflow.yaml

# Output example:
# └─> intake
#     ├─> [PARALLEL]
#     │   ├─> technical
#     │   ├─> business
#     │   └─> security
#     └─> synthesis

# Mermaid flowchart (for documentation)
paladin maneuver visualize -c workflow.yaml --format mermaid

# Save to file
paladin maneuver visualize -c workflow.yaml -f ascii -o flow.txt
```

#### `paladin maneuver validate`

Validate a Maneuver configuration for syntax and structure errors.

**Syntax:**
```bash
paladin maneuver validate -c <config> [-v]
```

**Options:**
- `-c, --config <PATH>` - Path to Maneuver YAML configuration (required)
- `-v, --verbose` - Show detailed validation output (optional)

**Validation Checks:**
- Flow expression syntax correctness
- All agents referenced in flow exist in configuration
- Agent configuration structure validity
- Provider settings correctness

**Examples:**
```bash
# Basic validation
paladin maneuver validate -c workflow.yaml

# Verbose validation with detailed output
paladin maneuver validate -c workflow.yaml --verbose
```

**Output (Success):**
```
✅ Flow syntax valid: intake -> (technical, business, security) -> synthesis
✅ All agents referenced in flow are configured
✅ Configuration structure valid
✅ 5 agents configured: intake, technical, business, security, synthesis
```

**Output (Error):**
```
❌ Flow syntax error at position 23: unexpected character '|'
   Expected: '->' or ',' for flow operators

❌ Agent 'reviewer' referenced in flow but not found in configuration
   Flow agents: [intake, technical, business, reviewer]
   Configured: [intake, technical, business]
```

---

### paladin arsenal

Manage and test external tools (MCP servers).

#### `paladin arsenal list`

List all configured MCP servers and their tools.

**Syntax:**
```bash
paladin arsenal list
```

**Example:**
```bash
paladin arsenal list

# Output:
# Tool Name       | Description          | Type   | Status
# ────────────────┼──────────────────────┼────────┼─────────
# web_search      | Search the web       | stdio  | ✓ Connected
# filesystem      | File operations      | stdio  | ✓ Connected
```

#### `paladin arsenal test`

Test connection to an MCP server.

**Syntax:**
```bash
paladin arsenal test --mcp-stdio <command>
paladin arsenal test --mcp-sse <url>
```

**Options:**
- `--mcp-stdio <COMMAND>` - Test STDIO MCP server (mutually exclusive with --mcp-sse)
- `--mcp-sse <URL>` - Test SSE MCP server (mutually exclusive with --mcp-stdio)

**Examples:**
```bash
# Test STDIO server
paladin arsenal test --mcp-stdio "uvx mcp-web-search"

# Test SSE server
paladin arsenal test --mcp-sse "http://localhost:3000/mcp"

# With full command and args
paladin arsenal test --mcp-stdio "npx -y @modelcontextprotocol/server-filesystem /tmp"
```

---

## Configuration Files

### Paladin Configuration Schema

```yaml
# Identity
name: "PaladinName"
user_name: "UserName"

# System prompt (most important!)
system_prompt: |
  Define the Paladin's role, capabilities, and behavior here.

# LLM settings
model: "gpt-4"
temperature: 0.7
max_loops: 3
timeout_seconds: 300
stop_words: ["STOP"]

# Provider
provider:
  type: openai  # or deepseek, anthropic

# Optional: Memory
garrison:
  type: sqlite
  path: ./garrison.db
  max_entries: 1000

# Optional: Tools
arsenal:
  mcp_servers:
    - name: web_search
      type: stdio
      command: uvx
      args: [mcp-web-search]
```

### Battalion Configuration Schema

**Formation (Sequential):**
```yaml
type: formation
name: "FormationName"
pass_output_to_next: true
paladins:
  - inline: { ... paladin config ... }
  - inline: { ... paladin config ... }
```

**Phalanx (Parallel):**
```yaml
type: phalanx
name: "PhalanxName"
paladins:
  - inline: { ... paladin config ... }
  - inline: { ... paladin config ... }
inputs: []  # Optional: different input for each
```

**Campaign (DAG):**
```yaml
type: campaign
name: "CampaignName"
nodes:
  - id: node1
    paladin: { inline: { ... } }
  - id: node2
    paladin: { inline: { ... } }
edges:
  - from: node1
    to: node2
start_node: node1
```

**Chain of Command (Hierarchical):**
```yaml
type: chain_of_command
name: "TeamName"
commander:
  inline: { ... paladin config ... }
delegates:
  - inline: { ... paladin config ... }
  - inline: { ... paladin config ... }
```

---

## Examples

### Example 1: Simple Q&A Agent

```bash
# 1. Create config
cat > qa-agent.yaml << 'EOF'
name: "QAAgent"
system_prompt: "You are a helpful Q&A assistant."
model: "gpt-4"
temperature: 0.7
max_loops: 1
provider: { type: openai }
EOF

# 2. Run
export OPENAI_API_KEY="sk-..."
paladin agent run -c qa-agent.yaml -i "What is Rust?"
```

### Example 2: Multi-Stage Analysis

```bash
# 1. Generate formation template
paladin battalion new -n Analysis -t formation -o analysis.yaml

# 2. Edit to add analyzer → summarizer → validator stages

# 3. Run
paladin battalion run -c analysis.yaml -i "$(cat document.txt)"
```

### Example 3: Agent with Web Search

```bash
# 1. Install MCP web search
pip install mcp-web-search

# 2. Create config with arsenal
cat > web-agent.yaml << 'EOF'
name: "WebAgent"
system_prompt: "You can search the web for current information."
model: "gpt-4"
temperature: 0.7
max_loops: 3
provider: { type: openai }
arsenal:
  mcp_servers:
    - name: web_search
      type: stdio
      command: uvx
      args: [mcp-web-search]
EOF

# 3. Run
paladin agent run -c web-agent.yaml -i "Latest AI news"
```

---

## Troubleshooting

### Common Errors

#### Error: "Missing API key"

**Problem:** Required environment variable not set.

**Solution:**
```bash
export OPENAI_API_KEY="sk-..."
# Or for other providers:
export DEEPSEEK_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-..."
```

#### Error: "Config file not found"

**Problem:** Path to configuration file is incorrect.

**Solution:**
- Use absolute paths: `/full/path/to/config.yaml`
- Or relative from current directory: `./config.yaml`
- Check file exists: `ls -l config.yaml`

#### Error: "Invalid YAML"

**Problem:** Syntax error in configuration file.

**Solution:**
- Validate YAML online: https://www.yamllint.com/
- Check indentation (use spaces, not tabs)
- Ensure all strings with special characters are quoted
- Use `yamllint config.yaml` if available

#### Error: "Invalid provider"

**Problem:** Provider type not recognized.

**Solution:**
- Valid providers: `openai`, `deepseek`, `anthropic`
- Check spelling in config file
- Use `paladin agent new -p <provider>` to generate correct template

#### Error: "MCP server connection failed"

**Problem:** Cannot connect to MCP server.

**Solution:**
- Verify server is installed: `which uvx`, `which npx`
- Test server manually: `uvx mcp-web-search`
- Check command and args in config
- Ensure server supports MCP protocol
- Review server logs in stderr

#### Error: "Timeout"

**Problem:** Execution exceeded configured timeout.

**Solution:**
- Increase `timeout_seconds` in config
- Reduce `max_loops` for simpler tasks
- Check if LLM API is responding slowly
- Verify network connectivity

#### Error: "Rate limit exceeded"

**Problem:** Too many API requests to LLM provider.

**Solution:**
- Wait and retry
- Use `--verbose` to see which call failed
- Consider using cheaper model for testing
- Check provider's rate limits
- Add delays between requests

### Getting Help

- **Documentation:** See `examples/cli_configs/` for working examples
- **Issues:** Report bugs at https://github.com/DF3NDR/paladin-dev-env/issues
- **Verbose Mode:** Use `--verbose` flag to see detailed execution logs
- **Logs:** Check stderr output for detailed error messages

### Performance Tips

1. **Model Selection:**
   - Use `gpt-3.5-turbo` for simple tasks (faster, cheaper)
   - Use `gpt-4` for complex reasoning
   - Use `deepseek-chat` for cost-effective alternative

2. **Temperature:**
   - Lower (0.0-0.3) for factual, consistent outputs
   - Medium (0.4-0.7) for balanced responses
   - Higher (0.8-1.0) for creative, varied outputs

3. **Max Loops:**
   - 1-2: Simple single-response tasks
   - 3-5: Default for most tasks
   - 6+: Complex multi-step reasoning

4. **Timeouts:**
   - 60s: Simple queries
   - 180-300s: Standard tasks
   - 600s+: Complex multi-step operations

5. **Battalions:**
   - Use Phalanx for parallel speedup
   - Use Formation for sequential pipelines
   - Monitor costs with `--verbose`

---

## Advanced Topics

### External Configuration References

Instead of inline Paladin configs, reference external files:

```yaml
paladins:
  - file: ./agents/analyzer.yaml
  - file: ./agents/summarizer.yaml
```

### Environment Variable Substitution

Use environment variables in configs:

```yaml
provider:
  api_key_env: "${CUSTOM_API_KEY_VAR}"
```

### Custom MCP Servers

Create your own tools:
- Implement MCP protocol
- Register in arsenal configuration
- See MCP documentation: https://modelcontextprotocol.io/

### Streaming Responses

For real-time output (coming soon):
```bash
paladin agent run -c config.yaml -i "Query" --stream
```

---

## See Also

### Documentation
- [CLI Configuration Guide]cli-configuration.md - Complete reference for garrison, arsenal, and scheduler configuration
- [CLI Testing Guide]../contributing/testing-guide.md - Guide for testing CLI commands
- [Main README]../introduction.md

### Configuration Examples
- [Basic Paladin Example]https://github.com/DF3NDR/paladin-dev-env/tree/main/examples/cli_configs
- [Advanced Paladin Example]https://github.com/DF3NDR/paladin-dev-env/tree/main/examples/cli_configs
- [Formation Example]https://github.com/DF3NDR/paladin-dev-env/tree/main/examples/cli_configs
- [Phalanx Example]https://github.com/DF3NDR/paladin-dev-env/tree/main/examples/cli_configs
- [Campaign Example]https://github.com/DF3NDR/paladin-dev-env/tree/main/examples/cli_configs
- [Chain of Command Example]https://github.com/DF3NDR/paladin-dev-env/tree/main/examples/cli_configs