Skip to content

Commit f616a65

Browse files
committed
fix: correct CLI syntax - use -p flag for non-interactive mode
- Add -p flag to all one-shot command examples - Add piping input examples - Fix CI mode with --allowedTools and --dangerously-skip-permissions - Clarify slash commands are used inside interactive session - Update shell alias usage examples
1 parent 9cb9899 commit f616a65

1 file changed

Lines changed: 49 additions & 13 deletions

File tree

README.md

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,63 @@ docker run -it --rm \
2929
ungb/claude-code
3030
```
3131

32-
### One-Shot Commands
32+
### One-Shot Commands (Non-Interactive)
33+
34+
Use the `-p` flag for non-interactive mode (prints result and exits):
3335

3436
```bash
3537
# Ask a question about your codebase
3638
docker run -it --rm \
3739
-v $(pwd):/workspace \
3840
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
3941
ungb/claude-code \
40-
claude "explain the architecture of this project"
42+
claude -p "explain the architecture of this project"
4143

4244
# Generate code
4345
docker run -it --rm \
4446
-v $(pwd):/workspace \
4547
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
4648
ungb/claude-code \
47-
claude "create a REST API endpoint for user authentication"
49+
claude -p "create a REST API endpoint for user authentication"
4850

4951
# Fix bugs
5052
docker run -it --rm \
5153
-v $(pwd):/workspace \
5254
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
5355
ungb/claude-code \
54-
claude "fix the failing tests in src/utils"
56+
claude -p "fix the failing tests in src/utils"
5557

5658
# Code review
5759
docker run -it --rm \
5860
-v $(pwd):/workspace \
5961
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
6062
ungb/claude-code \
61-
claude "review the changes in the last commit"
63+
claude -p "review the changes in the last commit"
64+
65+
# JSON output (for scripts/automation)
66+
docker run -it --rm \
67+
-v $(pwd):/workspace \
68+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
69+
ungb/claude-code \
70+
claude -p --output-format json "list all TODO comments"
71+
```
72+
73+
### Piping Input
74+
75+
```bash
76+
# Analyze a file
77+
cat README.md | docker run -i --rm \
78+
-v $(pwd):/workspace \
79+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
80+
ungb/claude-code \
81+
claude -p "summarize this document"
82+
83+
# Analyze git diff
84+
git diff | docker run -i --rm \
85+
-v $(pwd):/workspace \
86+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
87+
ungb/claude-code \
88+
claude -p "review these changes"
6289
```
6390

6491
### With Full Configuration (Recommended)
@@ -94,8 +121,8 @@ echo "ANTHROPIC_API_KEY=your-key-here" > .env
94121
# Interactive session
95122
docker compose run --rm claude
96123

97-
# One-shot command
98-
docker compose run --rm claude claude "explain this code"
124+
# One-shot command (non-interactive)
125+
docker compose run --rm claude claude -p "explain this code"
99126
```
100127

101128
### Resume a Conversation
@@ -113,12 +140,19 @@ docker run -it --rm \
113140
### Non-Interactive / CI Mode
114141

115142
```bash
116-
# Run without prompts (for scripts/CI)
117-
docker run -it --rm \
143+
# Run without interactive prompts (for scripts/CI)
144+
docker run --rm \
118145
-v $(pwd):/workspace \
119146
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
120147
ungb/claude-code \
121-
claude --yes "format all TypeScript files"
148+
claude -p --allowedTools "Bash(npm run format)" "format all TypeScript files"
149+
150+
# Skip all permission prompts (use with caution!)
151+
docker run --rm \
152+
-v $(pwd):/workspace \
153+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
154+
ungb/claude-code \
155+
claude -p --dangerously-skip-permissions "run the linter and fix issues"
122156
```
123157

124158
## Sharing Your Claude Configuration
@@ -160,8 +194,9 @@ docker run -it --rm \
160194
-v $(pwd):/workspace \
161195
-v ~/.claude:/home/coder/.claude \
162196
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
163-
ungb/claude-code \
164-
claude "/my-custom-command"
197+
ungb/claude-code
198+
199+
# Then inside the session, type: /my-custom-command
165200
```
166201

167202
### Project-Specific Configuration
@@ -393,7 +428,8 @@ alias claude-docker='docker run -it --rm \
393428
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
394429
ungb/claude-code claude'
395430

396-
# Usage: claude-docker "explain this code"
431+
# Usage (interactive): claude-docker
432+
# Usage (one-shot): claude-docker -p "explain this code"
397433
```
398434

399435
## License

0 commit comments

Comments
 (0)