An Emacs interface for the Amp CLI - Sourcegraph's AI-powered coding assistant.
- Interactive Terminal Interface: Launch Amp CLI in a dedicated terminal buffer within Emacs
- Multi-Project Support: Automatically manages separate Amp sessions for different projects
- Intelligent Project Detection: Works with both
projectile
andproject.el
for project identification - Quick Code Actions: Send selected code to Amp with predefined prompts
- Smart Process Management: Automatically handles multiple Amp processes and lets you choose between them
- Auto-Installation: Automatically installs Amp CLI via npm if not found
amp.el excels at managing multiple projects simultaneously:
- Project-Specific Sessions: Each project gets its own
*amp-{project-name}*
buffer - Automatic Project Detection: Uses projectile or project.el to identify current project
- Session Switching: When no Amp process exists for current project, you can choose from running sessions in other projects
- Buffer Management: Clean separation between different project contexts
amp--fix-region
: Send selected text with "fix this: " prefixamp--improve-region
: Send selected text with "improve this: " prefixamp--explain-region
: Send selected text with "explain this: " prefixamp--prompt-for-region
: Send selected text with custom promptamp--prompt
: Send custom text to ampamp--switch
: Switch between existing amp buffersamp--kill
: Kill selected amp processes
Add this to your Emacs configuration:
(straight-use-package
'(amp :type git :host github :repo "shaneikennedy/amp.el"))
-
Clone the repository:
git clone https://github.com/shaneikennedy/amp.el.git
-
Add to your Emacs
load-path
:(add-to-list 'load-path "/path/to/amp.el") (require 'amp)
- Run
M-x amp
to start Amp in the current project - If Amp CLI isn't installed, it will offer to install it via npm
- The Amp CLI will open in a terminal buffer named
*amp-{project-name}*
- Select code in any buffer
- Run
M-x amp--fix-region
to send code with "fix this: " prefix - Run
M-x amp--improve-region
to send code with "improve this: " prefix - Run
M-x amp--explain-region
to send code with "explain this: " prefix - Run
M-x amp--prompt-for-region
to send code with custom prompt
M-x amp--prompt
: Send custom text directly to amp (no region required)M-x amp--kill
: Kill selected amp processes
Run M-x amp--switch
to quickly jump between amp buffers from different projects or sessions.
The amp buffer uses terminal char mode by default. If you need to use Emacs commands like M-x
:
- Press
C-c C-j
to switch to line mode (enables normal Emacs commands) - Press
C-c C-k
to switch back to char mode (direct terminal interaction)
Add these to your configuration for quick access:
(global-set-key (kbd "C-c a a") 'amp)
(global-set-key (kbd "C-c a f") 'amp--fix-region)
(global-set-key (kbd "C-c a i") 'amp--improve-region)
(global-set-key (kbd "C-c a e") 'amp--explain-region)
(global-set-key (kbd "C-c a p") 'amp--prompt-for-region)
(global-set-key (kbd "C-c a m") 'amp--prompt)
(global-set-key (kbd "C-c a s") 'amp--switch)
(global-set-key (kbd "C-c a k") 'amp--kill)
- Emacs 28.1 or later
- Node.js and npm (for Amp CLI installation)
- Optional:
projectile
orproject.el
for enhanced project detection
This project is licensed under the same terms as GNU Emacs.