Skip to content

feat(cli): support custom extension hooks and skills directories - #25008

Open
skainguyen1412 wants to merge 4 commits into
google-gemini:mainfrom
skainguyen1412:feat/issue-19969-custom-extension-dirs
Open

skainguyen1412 wants to merge 4 commits into
google-gemini:mainfrom
skainguyen1412:feat/issue-19969-custom-extension-dirs

Conversation

@skainguyen1412

Copy link
Copy Markdown

Summary

Add support for custom extension hooks and skills directories via optional hooksDir and skillsDir fields in gemini-extension.json.

This lets extension authors reuse existing repository layouts without being forced to place content under hooks/ and skills/, while preserving the current default behavior for existing extensions.

Details

  • Add optional hooksDir and skillsDir manifest fields.
  • Keep backward compatibility by defaulting to hooks/ and skills/ when the new fields are not provided.
  • Update extension loading so hooks and skills resolve from the configured relative directories.
  • Validate configured directories so they cannot escape the extension root.
  • Update folder trust discovery and local install/trust detection so custom
    hooks and skills directories are included in safety prompts.
  • Add regression coverage to ensure hooks discovered from settings and extension manifests are merged without losing entries.
  • Update extension documentation and examples to use Gemini-specific directory names such as gemini-hooks and gemini-skills.

Related Issues

Closes #19969

How to Validate

  1. Run the CLI-focused tests:

    npm run test --workspace @google/gemini-cli -- \
      src/config/extension.test.ts \
      src/config/extension-manager-hydration.test.ts \
      src/config/extension-manager-skills.test.ts \
      src/commands/extensions/install.test.ts

    Expected result: all targeted CLI tests pass.

  2. Run the core trust-discovery tests:

    npm run test --workspace @google/gemini-cli-core -- \
      src/services/FolderTrustDiscoveryService.test.ts

    Expected result: all targeted core tests pass.

  3. Verify backward compatibility:

    • Use an extension that does not set hooksDir or skillsDir.
    • Expected result: Gemini CLI still loads hooks/hooks.json and skills/
      exactly as before.
  4. Verify custom directory support:

    • Use an extension manifest with:
      {
        "hooksDir": "gemini-hooks",
        "skillsDir": "gemini-skills"
      }
    • Place hooks in gemini-hooks/hooks.json.
    • Place a skill in gemini-skills/<skill-name>/SKILL.md.
    • Expected result: Gemini CLI loads both successfully.
  5. Verify path safety:

    • Set hooksDir or skillsDir to a path outside the extension root, such
      as ../shared-hooks.
    • Expected result: the configuration is rejected and no files outside the
      extension directory are loaded.

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

@skainguyen1412
skainguyen1412 requested review from a team as code owners April 9, 2026 07:27
@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 significantly enhances the flexibility of the Gemini CLI by allowing extension authors to define custom directory paths for their hooks and skills. This change enables better integration with diverse repository structures, moving away from a rigid default directory layout. It ensures that extensions can be organized more intuitively while maintaining robust security through path validation and preserving full backward compatibility for existing extensions.

Highlights

  • Custom Extension Directories: Added support for optional hooksDir and skillsDir fields in gemini-extension.json to allow extension authors to specify custom directories for their hooks and skills.
  • Backward Compatibility: Maintained backward compatibility by defaulting to the traditional hooks/ and skills/ directories when the new custom directory fields are not provided.
  • Path Validation and Security: Implemented validation to ensure that configured custom directories for hooks and skills cannot escape the extension's root directory, enhancing security.
  • Updated Discovery and Trust Mechanisms: Modified folder trust discovery and local install/trust detection processes to correctly identify and include content from custom hooks and skills directories in safety prompts.
  • Comprehensive Testing and Documentation: Included new test cases to cover custom directory functionality, path safety, and hook merging, and updated extension documentation and examples to reflect these changes.
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.

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. ↩

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

Copy link
Copy Markdown
Contributor

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 support for custom directories for extension hooks and skills by adding hooksDir and skillsDir configuration options to the extension manifest. It updates the extension manager and discovery service to resolve these paths safely within the extension directory and includes comprehensive tests for these new capabilities. I have provided a security-focused suggestion to sanitize hook identifiers to prevent potential prompt injection vulnerabilities.

@gemini-cli gemini-cli Bot added area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Apr 9, 2026
@skainguyen1412

Copy link
Copy Markdown
Author

Can you take a look, @cocosheng-g? Feel free to suggest any changes, and let me know if you need me to handle anything.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! size/l A large sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a way to control the standard names of hooks and skills folder via gemini-extension.json of an extension

2 participants