Jules Actions

repository·main·Indexed 42 days ago

https://github.com/google-labs-code/jules-action

A GitHub Action that invokes a remote AI coding agent powered by Gemini 3 Pro to autonomously analyze codebases, fix bugs, improve performance, and create pull requests. It includes specialized workflows for automated debugging (bug-fixer.yml), codebase maintenance (weekly-cleanup.yml), performance optimization (performance-improver.yml), and CI failure repair (ci-failure-fix.yml). The google-labs-code/jules-invoke@v1 action requires a prompt and a JULES_API_KEY to operate.

Tokens
2K
Snippets
6
Records
11
Agent score
4%

What's inside Jules Actions

  1. Quick Start: Set up Jules Actions

    main

    To use Jules Actions in your GitHub repository, follow these three steps:

    1. Get a Jules API Key: Authenticate at jules.google.com and generate an API key from your account settings.
    2. Add to GitHub Secrets: In your repository, navigate to Settings → Secrets and variables → Actions. Create a new repository secret named JULES_API_KEY and paste your key as the value.
    3. Create a Workflow: Create a .yml file in .github/workflows/ to define when and how Jules should run (e.g., on a schedule, on an issue, or via manual dispatch).
    name: Daily Security Scan
    
    on:
      schedule:
        - cron: '0 6 * * *'  # Every day at 6 AM
      workflow_dispatch:
    
    jobs:
      scan:
        runs-on: ubuntu-latest
        permissions:
          contents: read
        steps:
          - uses: google-labs-code/jules-invoke@v1
            with:
              prompt: |
                You are a security agent. Scan for vulnerabilities and fix them...
              jules_api_key: ${{ secrets.JULES_API_KEY }}
  2. Writing effective prompts for Jules

    main

    Jules performs best when provided with clear specifications or measurable targets. For automated or scheduled workflows, it is highly effective to give Jules a loop of execution: run a tool (like a benchmark or audit), identify issues, implement fixes, and verify the results.

    Best practices for prompts:

    • Define a specific persona (e.g., "You are a performance improvement agent").
    • Provide step-by-step instructions (e.g., 1. Run benchmarks, 2. Identify bottlenecks, 3. Implement changes).
    • Include verification steps (e.g., "Re-run benchmarks to verify improvement").
    • Set constraints (e.g., "Don't change public API contracts", "Keep changes under 100 lines").
    # Example of a high-quality prompt for a scheduled agent
    steps:
      - uses: google-labs-code/jules-invoke@v1
        with:
          prompt: |
            You are a performance improvement agent. Run our benchmark suite
            and look for optimization opportunities:
    
            1. Run `npm run bench` to get current metrics
            2. Identify the slowest endpoints or functions
            3. Implement optimizations (caching, query improvements, algorithm changes)
            4. Re-run benchmarks to verify improvement
            5. Only open a PR if you achieve measurable gains
    
            Constraints:
            - Don't change public API contracts
            - All existing tests must pass
          jules_api_key: ${{ secrets.JULES_API_KEY }}
  3. Secure Jules workflows with user allowlists

    main

    To prevent abuse, all issue-triggered workflows should include a user allowlist. This ensures that only trusted users can trigger Jules actions.

    In your workflow YAML, replace the placeholder array with your actual trusted GitHub usernames.

    ["your-username", "trusted-collaborator"]
  4. Securely triggering Jules from GitHub Issues

    main

    Because GitHub issues can be created by anyone, triggering Jules via an issue event can be a security risk. To prevent unauthorized use of your API key, implement an allowlist condition in your workflow step using the if conditional. This ensures Jules only runs if the user who triggered the event is in your trusted list.

    - name: Invoke Jules
      # Only runs if user is in the allowlist
      if: ${{ contains(fromJSON('["trusted-user", "another-user"]'), github.event.issue.user.login) }}
      uses: google-labs-code/jules-invoke@v1
      with:
        prompt: ...
        jules_api_key: ${{ secrets.JULES_API_KEY }}
  5. Use the weekly-cleanup workflow for codebase maintenance

    main

    The weekly-cleanup.yml workflow is designed for automated maintenance, such as removing dead code, reducing duplication, and improving naming. It can be triggered via a cron schedule (default: Mondays at 2 AM UTC) or manually.

    Customization options:

    • Adjust the cron schedule.
    • Modify the prompt to add or remove specific focus areas.
    • Target specific directories in the prompt.
  6. Use the unblocked-issues workflow for dependency management

    main

    The unblocked-issues.yml workflow triggers when an issue is closed. It uses the on-unblocked action to identify issues that were waiting on the closed issue and automatically starts working on them.

    Setup requirements:

    1. Use the blocked by #123 syntax in your issue descriptions to create dependencies.
    2. When issue #123 is closed, Jules will trigger for all issues blocked by it.
  7. Use the bug-fixer workflow for automated debugging

    main

    The bug-fixer.yml workflow is triggered when an issue is labeled with bug. Jules will analyze the issue, trace the cause, apply a fix, and add regression tests.

    Best practices for issues:

    • Include error messages and stack traces.
    • Describe expected vs. actual behavior.
    • Provide steps to reproduce the bug.
  8. Use the performance-improver workflow for optimizations

    main

    The performance-improver.yml workflow acts as a performance optimization agent. It runs on a daily schedule (4 AM UTC) or manually.

    Optimization targets:

    • Frontend: Unnecessary re-renders, code splitting, unoptimized images.
    • Backend: N+1 queries, missing indexes, caching opportunities.
    • General: $O(n^2)$ algorithms, redundant calculations, inefficient data structures.

    Behavioral constraints:

    • Only creates a Pull Request (PR) if there is a measurable impact.
    • Keeps changes under 50 lines.
    • Includes the expected performance improvement in the PR description.
  9. Use the ci-failure-fix workflow to repair CI breaks

    main

    The ci-failure-fix.yml workflow triggers when a CI workflow fails. Jules analyzes the failure and proposes a fix on the failing branch. It is most effective for fixing test failures and lint errors.

    Setup requirement: You must update the workflows input to match the name of your actual CI workflow.

    workflows: ["YOUR_CI_WORKFLOW_NAME"]
  10. Combine multiple Jules tasks in a single workflow

    main

    You can use conditional logic within a single GitHub Action job to handle different types of issues (e.g., features vs. bugs) using different prompts based on the issue label.

    # Feature + Bug in one workflow
    name: Jules Issue Handler
    on:
      issues:
        types: [labeled]
    
    jobs:
      handle:
        if: contains(fromJSON('["feature", "bug"]'), github.event.label.name)
        # ... use different prompts based on label
  11. Jules Action Inputs

    main

    The google-labs-code/jules-invoke@v1 action accepts the following inputs:

    InputDescriptionDefault
    promptRequired. The task for Jules to perform.—
    jules_api_keyRequired. Your Jules API key (use secrets).—
    starting_branchBranch for Jules to start from.main
    include_last_commitInclude the last commit's diff in context.false
    include_commit_logInclude recent commit history in context.false