Commit 784b6e4
feat(deploy): significantly improve agent experience (AX) with non-interactive deploy support (#7552)
* feat(deploy): significantly improve agent experience with better non-interactive support
This change dramatically improves the "agent experience" (AX) for AI agents and automated tools using the deploy command:
**Key Improvements:**
- Added `--create [name]` flag to create and deploy sites in one command
- Added `--team <slug>` flag for explicit team selection when creating sites
- Intelligent team handling: auto-use single team, require explicit selection for multiple teams
- Comprehensive help text with copy-pasteable commands shown at every interactive prompt
- Proper command parsing with optional site names (`--create` vs `--create sitename`)
**Agent Flow Example:**
Before: Agents got stuck in interactive menus when deploying new projects
After: Agents can successfully deploy with: `netlify deploy --create my-site --team my-team --dir . --prod`
**Interactive Improvements:**
- Show copy-pasteable commands before every prompt
- Context-aware help text (includes current flags like --prod, --dir, etc.)
- Better team selection messaging when multiple teams available
- Cleaner help text when only one team available
**Validation & Error Handling:**
- Proper TypeScript types for new flags (`create?: string | boolean`)
- Validation that --team only works with --create
- Clear error messages with actionable examples
- Smart fallbacks for single vs multiple team scenarios
This maintains full backward compatibility while enabling seamless automated deployments.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor(deploy): eliminate code duplication in command generation
Removed duplicate command generation logic in prepareProductionDeploy by reusing the shared generateDeployCommand helper function. This improves maintainability and ensures consistent command generation across all scenarios.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(deploy): remove emojis from help text and fix locked deployment instructions
- Removed emojis from all help text messages for cleaner CLI output
- Fixed locked deployment instructions to use --prod-if-unlocked flag instead of manual unlock
- Added proper warning about only using --prod-if-unlocked when absolutely sure
- Updated generateDeployCommand to support prodIfUnlocked flag
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor(deploy): derive flag map programmatically from Commander.js options
Refactored generateDeployCommand to derive available flags from the actual Commander.js command definition instead of maintaining a hardcoded flagMap. This approach:
- Eliminates manual flag mapping maintenance
- Automatically includes new flags as they're added to the command
- Uses command.options to introspect actual option definitions
- Handles all option types (string, number, boolean) correctly
- Maintains special handling for quoted message values
The function now dynamically builds commands from the live command definition, making it more maintainable and less prone to drift.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(deploy): preserve all original flags in generated commands
Removed unnecessary filtering of hidden and deprecated options from generateDeployCommand. If users included these flags in their original command, they should be preserved in the copyable command for consistency.
This ensures the generated command exactly matches what the user originally attempted to run.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* remove(teams): remove unnecessary netlify teams command
The teams command is not needed since the deploy command now properly handles team selection with clear error messages that list available teams when multiple teams are present.
This simplifies the codebase while maintaining all necessary functionality for both interactive and non-interactive team selection.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* Clean CLAUDE.md file
* refactor(deploy): rename --create flag to --create-site for clarity
Change the --create flag to --create-site in the deploy command to make
the flag name more explicit and descriptive. This improves clarity about
what the flag does when creating new sites during deployment.
Changes:
- Rename --create flag to --create-site in command definition
- Update all option references from options.create to options.createSite
- Update help text and examples to use new flag name
- Update TypeScript types to reflect the change
- Maintain existing functionality and validation logic
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor(bin): simplify error handling in run.js
Change error handling from explicit .catch() with process.exit(1)
back to simple top-level await. This removes the explicit fatal
error logging and process exit, allowing errors to bubble up naturally.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(deploy): prevent duplicate --build and --no-build flags in generated commands
Fix the generateDeployCommand function to properly handle Commander.js
negatable boolean options. Previously, both --build and --no-build flags
were being added to generated command suggestions, causing confusing
output like "netlify deploy --create-site <NAME> --build --no-build".
Changes:
- Add special handling for the 'build' option to only show --no-build when build is false
- Skip processing the --no-build option separately since it's handled with build logic
- Add flag deduplication to prevent any duplicate flags in generated commands
- Maintain clean command suggestions without redundant or conflicting flags
This ensures users get clean, actionable command suggestions without
conflicting flags that would cause command errors.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor(deploy): simplify generateDeployCommand with generic negated flag handling
Replace complex special-case logic with clean, generic handling for any
--no-* flags. Only include negated flags when explicitly used by the user
(value === false). Remove verbose comments and deduplication logic in favor
of preventing issues at the source.
Changes:
- Generic handling for all --no-* flags instead of hardcoding --no-build
- Remove special build flag logic and deduplication
- Clean up verbose comments for better code readability
- Maintain functionality: include --no-build only when user specifies it
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor(deploy): extract site creation logic into focused functions
Replace complex nested if/else chains with clean, single-purpose functions.
The site creation logic was deeply nested with multiple levels of branching
that was hard to follow and maintain.
Changes:
- Extract ensureSiteExists() as main entry point with clear branching
- Add createSiteWithFlags() for --create-site flag handling
- Add validateTeamForSiteCreation() for team validation logic
- Add promptForSiteAction() for interactive site selection
- Use early returns to eliminate nesting levels
- Remove verbose comments in favor of self-documenting code
Results in cleaner, more testable code with the same functionality.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(deploy): resolve linting issues in refactored site creation functions
Fix ESLint errors introduced in the site creation logic refactor:
- Use optional chaining for option.long?.startsWith()
- Replace any types with proper TypeScript types ($TSFixMe, SiteInfo)
- Ensure all code follows project linting standards
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* Tweak deploy command description
* Remove + from Create and configure menu option
* style: fix prettier formatting issues
Apply prettier formatting to files that were not properly formatted.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* test: update help command snapshot for deploy description
Update the help command snapshot to reflect the new deploy command
description that was changed from 'Create a new deploy from the contents
of a folder' to 'Deploy your project to Netlify'.
This fixes the failing CI/CD integration tests.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* style: fix prettier formatting for init and gh-auth files
Apply prettier formatting to resolve code style warnings.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* docs: sync documentation for deploy command changes
Update auto-generated documentation to reflect:
- New deploy command description: 'Deploy your project to Netlify'
- Added --create-site flag documentation
- Added --team flag documentation
- Updated examples with new flag usage
- Improved command description and help text
Generated via: npm run docs
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>1 parent bd4e641 commit 784b6e4
File tree
8 files changed
+343
-171
lines changed- docs
- commands
- src/commands
- deploy
- sites
- tests/integration/commands/help/__snapshots__
8 files changed
+343
-171
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
12 | 11 | | |
13 | | - | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
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 | | - | |
| 21 | + | |
78 | 22 | | |
79 | 23 | | |
80 | 24 | | |
| |||
86 | 30 | | |
87 | 31 | | |
88 | 32 | | |
| 33 | + | |
89 | 34 | | |
90 | 35 | | |
91 | 36 | | |
| |||
99 | 44 | | |
100 | 45 | | |
101 | 46 | | |
| 47 | + | |
102 | 48 | | |
103 | 49 | | |
104 | 50 | | |
| |||
115 | 61 | | |
116 | 62 | | |
117 | 63 | | |
| 64 | + | |
118 | 65 | | |
119 | 66 | | |
120 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments