Skip to content

Support reading prompt from a file via --file / -f flag #67

@chanakyav

Description

@chanakyav

Problem

When users have long or complex prompts, pasting them directly into CLI args causes issues:

  • Shell escaping corrupts special characters
  • Terminals truncate long text
  • The prompt that reaches the agent may not match what the user intended
  • Only the first 100 chars are logged at INFO level, making it hard to verify what was actually sent

Proposed Solution

Add a --file / -f flag to autopilot start that reads the prompt from a file.

# Write your prompt in a file
autopilot start --file my-task.txt

# Equivalent to --prompt but avoids shell corruption
autopilot start -f instructions.md

File format

Plain text — the entire file content becomes the prompt. No special format required.

Prompt file protection (two layers)

Since the agent has full write access (--allow-all), we need to protect the prompt file from being modified, committed, or pushed:

  1. Git exclusion: Dynamically append the file's repo-relative path to .git/info/exclude (local-only, never committed). Prevents the file from being staged even if the agent runs git add ..
  2. Agent instruction: Prepend an explicit instruction to the agent prompt: "Do NOT read, modify, rename, or delete the file <path>. It contains the task instructions and must remain unchanged."

Full prompt logging

Replace the truncated %.100s log in agent.py with full prompt logging at INFO level, so users have complete visibility into what the agent is actually executing. Also log prompt metadata (source, length) at task start.

Mutual exclusivity

--file, --prompt, and --issue are mutually exclusive — exactly one must be provided.

Implementation

  1. Add --file / -f argument to start subparser in cli.py
  2. Update cmd_start() prompt resolution — read file, validate exists + non-empty
  3. Add prompt_file column to persistence schema (schema migration)
  4. Append file path to .git/info/exclude (idempotent)
  5. Add protection instruction to implement_prompt(), plan_and_implement_prompt(), fix_prompt() in prompts.py
  6. Pass prompt_file through orchestrator.py → prompt construction
  7. Log full prompt at INFO level in agent.py
  8. Log prompt source + length in cmd_start()
  9. Tests: happy path, file not found, empty file, mutual exclusivity, git exclude, prompt construction
  10. Update README and CLI docstring

Related


🤖 autopilot-loop

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions