Skip to content

feat(cli): Add 'list' subcommand to '/commands'#22324

Open
Jwhyee wants to merge 23 commits intogoogle-gemini:mainfrom
Jwhyee:feat/add-commands-list
Open

feat(cli): Add 'list' subcommand to '/commands'#22324
Jwhyee wants to merge 23 commits intogoogle-gemini:mainfrom
Jwhyee:feat/add-commands-list

Conversation

@Jwhyee
Copy link
Copy Markdown

@Jwhyee Jwhyee commented Mar 13, 2026

Summary

Adds a list subcommand to the /commands utility to display all currently loaded .toml command files. This improves the developer experience by allowing users to quickly verify which custom commands and prompts are active without manually inspecting the file system.

Details

Currently, the /commands command only supports the reload subcommand. This PR introduces the list subcommand, which reads and outputs the filenames from the directories evaluated by the CLI (user-level ~/.gemini/commands/, project-level <project>/.gemini/commands/, MCP prompts, and extensions).

  • Added unit tests in commandsCommand.test.ts to ensure the correct paths are scanned and listed.
  • Updated user-facing documentation in docs/reference/commands.md.

Related Issues

Fixes #22321

How to Validate

  1. Build and start the CLI locally: npm run build followed by npm start.
  2. Add a dummy .toml file to ~/.gemini/commands/ or <project>/.gemini/commands/.
  3. Inside the CLI prompt, execute /commands list.
  4. Verify that the output accurately reflects the .toml files present in those directories.
  5. Run the test suite to ensure no regressions: npm run test.
  6. Run npm run preflight to confirm formatting and linting pass.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@Jwhyee Jwhyee requested review from a team as code owners March 13, 2026 14:38
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new list subcommand to the /commands utility, enhancing the developer experience by providing a straightforward way to view all active custom commands. The changes include modifications to the command logic, addition of unit tests, and updates to the user documentation.

Highlights

  • New 'list' Subcommand: Introduced a 'list' subcommand to the /commands utility, enabling users to view all loaded .toml command files.
  • Improved Developer Experience: Allows developers to quickly verify active custom commands and prompts without manual file system inspection.
  • Comprehensive File Listing: The 'list' subcommand reads and outputs filenames from user-level, project-level, MCP prompts, and extensions directories.
  • Added Unit Tests: Implemented unit tests in commandsCommand.test.ts to ensure correct path scanning and listing.
  • Updated Documentation: Updated user-facing documentation in docs/reference/commands.md to reflect the new subcommand.
Changelog
  • docs/reference/commands.md
    • Added documentation for the new list subcommand.
  • packages/cli/src/ui/commands/commandsCommand.test.ts
    • Added unit tests for the list subcommand, mocking file system interactions and command contexts to ensure correct functionality.
  • packages/cli/src/ui/commands/commandsCommand.ts
    • Implemented the list subcommand, including logic to gather and display .toml command files from various sources.
    • Modified the default action to include a reference to the new list subcommand.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a list subcommand to /commands, allowing users to see all loaded custom command files. The implementation is straightforward and includes corresponding documentation and tests. My main feedback is to improve error handling when scanning for command files to provide better diagnostics for users, ensuring detailed logging for unexpected errors as per best practices.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Mar 13, 2026
Jwhyee and others added 2 commits March 14, 2026 10:47
- Refactor FileCommandLoader to expose getCommandDirectories
- Improve error handling with isNodeError and add internal debugLogger
- Fix strict typing issues in tests
- Add mock cleanup (restoreAllMocks) in afterEach
@Jwhyee
Copy link
Copy Markdown
Author

Jwhyee commented Mar 14, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a useful list subcommand to the /commands utility, allowing users to see all loaded .toml command files. The implementation is well-structured and includes corresponding documentation and unit tests. I've identified one area for improvement regarding code duplication in commandsCommand.ts to enhance maintainability.

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Mar 28, 2026

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

@gemini-cli gemini-cli bot closed this Mar 28, 2026
@cocosheng-g cocosheng-g reopened this Apr 8, 2026
@cocosheng-g
Copy link
Copy Markdown
Contributor

@Jwhyee, apologies for the bot closing this PR! We have reopened it. Please sync your branch to the latest main and we will have someone review it shortly.

@gemini-cli gemini-cli bot added the help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! label Apr 8, 2026
@cocosheng-g
Copy link
Copy Markdown
Contributor

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new /commands list sub-command to the CLI, enabling users to view available custom .toml command files from user, project, and extension sources. The changes include the implementation of listAvailableFiles in the FileCommandLoader service, the addition of the list sub-command action in the UI layer, corresponding documentation updates, and new unit tests to verify the functionality. There are no review comments to address, and I have no further feedback to provide.

@cocosheng-g
Copy link
Copy Markdown
Contributor

Please fix test failures.

@cocosheng-g cocosheng-g self-requested a review April 8, 2026 20:02
@Jwhyee
Copy link
Copy Markdown
Author

Jwhyee commented Apr 9, 2026

@cocosheng-g Fixed test failures! A type error introduced by the upstream merge. context.services.agentContext?.config was returning undefined instead of null, which caused a type mismatch in FileCommandLoader. Added ?? null to handle it.

@cocosheng-g cocosheng-g enabled auto-merge April 9, 2026 13:55
@Jwhyee
Copy link
Copy Markdown
Author

Jwhyee commented Apr 9, 2026

@cocosheng-g Thanks for enabling auto-merge! The docs-pr-check has been queued for over 3 hours without running. is there anything I need to do on my end, or does this need a re-trigger?

@cocosheng-g
Copy link
Copy Markdown
Contributor

Requesting review from gemini-cli-docs

auto-merge was automatically disabled April 10, 2026 02:56

Head branch was pushed to by a user without write access

Copy link
Copy Markdown
Contributor

@jkcinouye jkcinouye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - docs.

One minor. note.

@Jwhyee
Copy link
Copy Markdown
Author

Jwhyee commented Apr 10, 2026

@jkcinouye Thank you for the suggestion. I've applied the changes to make it read more naturally.

@cocosheng-g cocosheng-g enabled auto-merge April 10, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add 'list' subcommand to '/commands' to show loaded command files

4 participants