When you have a quick, one-off task, you don’t need to start a whole chat thread. Instead, you can run Amp CLI commands directly. Ask once, get your result, and you’re done. For example, let’s look at how to use the -x
command to generate project documentation.
What is Amp CLI?
Amp CLI is an interactive console. It’s how you chat with a chatbot but in a terminal interface. When you start a session, Amp listens to your commands, returns results, and keeps track of the conversation context for follow-up questions.
It’s like opening a chat window right in your terminal. Since Amp keeps the thread alive, you build on top of prior answers.
Sometimes you don’t need a full chatbot thread; you just want to run a single command, get the result, and immediately close the session. For this, we have the --execute
command.
Amp --execute
command
Once you’re logged in to Amp through your terminal, you can run:
amp -x "your prompt"
In this mode, Amp processes your prompt once, performs the task, and immediately closes the session.
Using Amp to generate project documentation
Let’s ask Amp to create documentation.
Inside the project repo, run the following prompt:
amp -x "create a README.md with installation and usage instructions"
Now, run cat readme.md
. It opens a README.md file as follows:
You can also create release notes using Amp code. You can either prompt directly as shown above, or create a bootstrap/text file with detailed instructions and execute it using the -x
command.
Since you already know how to prompt directly, I’ll show you the bootstrap method.
First, save the following instructions in a text file. I’ll save it as release-notes.prompt.txt
Task: Create RELEASE_NOTES.md for non-technical readers.
Source: Summarize the following changelog content.
Include:
- What’s new in plain English.
- Impact, risks, rollback summary.
- Upgrade checklist.
Now run the below command:
amp -x "$(cat release-notes.prompt.txt)" > RELEASE_NOTES.md
As instructed in the text file, this generates a RELEASE_NOTES.md file and populates it with the latest release changes using the changelog.
Conclusion
When you have a set of pre-defined tasks or you have a one-time task, you can easily execute them using the -x
command. You can also integrate -x
commands into Git hooks or CI/CD pipelines so that it performs the set instructions on every commit, tag, or release.
For example, you could set up a script to check for security issues, wrap it in a -x
command, and automate it to run with every build.
Top comments (0)