[PR #6188] feat: Add opencode init command with interactive setup and AI-powered AGENTS.md generation #11769

Open
opened 2026-02-16 18:16:42 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6188

State: open
Merged: No


Summary

Adds a new opencode init command that provides an interactive setup wizard for initializing OpenCode in a project. Currently, by default, all projects have "allow all" permissions for everything (webfetch, bash, edit, etc.), which is risky. Most people don't create an opencode.jsonc file on their own because they probably don't even know it exists (reading docs has become a thing of the past lol). The opencode init command solves this by walking users through permission configuration interactively and also performs the same codebase analysis that the /init slash command does to generate project-specific AGENTS.md instructions.

Changes

New Command: opencode init
Features:

  • Interactive permission configuration for bash, edit, webfetch, and skill tools
  • AI-powered generation of AGENTS.md by analyzing the codebase using the /init command
  • Automatic .gitignore management for opencode.jsonc
  • Non-interactive mode with --skip flag for automation

Behavior

Interactive Mode (opencode init)

  1. Permission Configuration: Prompts for bash, edit, webfetch, and skill permissions
  2. Config File:
    • Creates opencode.jsonc with selected permissions
    • If exists, asks to overwrite (default: No)
  3. AGENTS.md Generation:
    • If doesn't exist: "Generate AGENTS.md by analyzing your codebase with AI?" (default: Yes)
    • If exists: "AGENTS.md already exists. Regenerate by re-analyzing your codebase with AI?" (default: No)
    • Uses AI to analyze codebase and generate project-specific instructions
    • Shows spinner during generation with 2-minute timeout
  4. Gitignore: Adds opencode.jsonc to .gitignore (or creates it)
    Skip Mode (opencode init --skip)
  • Uses default "allow all" permissions
  • Skips all prompts for scripting/automation
  • Minimal console output
  • Skips AGENTS.md generation

Testing

Tested both interactive and skip modes:

Interactive mode

opencode init

Skip mode for automation

opencode init --skip
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6188 **State:** open **Merged:** No --- # Summary Adds a new `opencode init` command that provides an interactive setup wizard for initializing OpenCode in a project. Currently, by default, all projects have "allow all" permissions for everything (webfetch, bash, edit, etc.), which is risky. Most people don't create an `opencode.jsonc` file on their own because they probably don't even know it exists (reading docs has become a thing of the past lol). The `opencode init` command solves this by walking users through permission configuration interactively and also performs the same codebase analysis that the `/init` slash command does to generate project-specific `AGENTS.md` instructions. # Changes New Command: `opencode init` **Features:** - Interactive permission configuration for bash, edit, webfetch, and skill tools - AI-powered generation of `AGENTS.md` by analyzing the codebase using the `/init` command - Automatic `.gitignore` management for `opencode.jsonc` - Non-interactive mode with `--skip` flag for automation # Behavior Interactive Mode (`opencode init`) 1. **Permission Configuration**: Prompts for bash, edit, webfetch, and skill permissions 2. **Config File**: - Creates `opencode.jsonc` with selected permissions - If exists, asks to overwrite (default: No) 3. **AGENTS.md Generation**: - If doesn't exist: "Generate AGENTS.md by analyzing your codebase with AI?" (default: Yes) - If exists: "AGENTS.md already exists. Regenerate by re-analyzing your codebase with AI?" (default: No) - Uses AI to analyze codebase and generate project-specific instructions - Shows spinner during generation with 2-minute timeout 4. **Gitignore**: Adds `opencode.jsonc` to `.gitignore` (or creates it) Skip Mode (`opencode init --skip`) - Uses default "allow all" permissions - Skips all prompts for scripting/automation - Minimal console output - Skips AGENTS.md generation # Testing Tested both interactive and skip modes: ## Interactive mode ```sh opencode init ``` # Skip mode for automation ```sh opencode init --skip ```
yindo added the pull-request label 2026-02-16 18:16:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11769