Terminal AI-Assisted Development Guide: From Configuration to Verifiable Workflows

    This article explains how to set up terminal-based AI coding tools with clear permission boundaries, project memory, skills, subagents, hooks, external protocol integrations, TDD, and multi-agent Git workflows. It emphasizes verifiable controls such as allowlists, denial tests, compaction checks, index measurement, blocking hooks, audit logging, and isolated worktrees so teams can use AI assistance without losing reviewability or security.

    Terminal AI-Assisted Development Guide: From Configuration to Verifiable Workflows

    Scope and Prerequisites

    This article applies to AI coding tools that can read and write files and execute commands in a terminal. Configuration file names, field names, and commands differ across tools; the examples here show structure only. Before implementation, verify each field name and command against the official documentation and current version of the tool you use.

    This article does not cover configuration of graphical interface plugins or model training.

    1. Environment Configuration: Define Permission Boundaries First

    Before using an AI tool, determine what it can and cannot do. Permission boundaries prevent accidents more effectively than prompt techniques.

    Configuration has three layers:

    1. User-level global configuration: Stored in the user home directory, this sets the default model and general preferences. Do not put project-specific command allowlists here.
    2. Project-level configuration: Stored in the repository root and committed to version control. Include only team-shared rules, such as permitted test commands and paths that must not be accessed.
    3. Local override configuration: Applies only to the local machine and is added to .gitignore. Put personal preferences and temporary debugging switches here.

    The following is a structural example. Replace the field names with the real fields used by your tool:

    1. {
    2. "permissions": {
    3. "allow": [
    4. "Read",
    5. "Bash(pytest -q)",
    6. "Bash(ruff check .)",
    7. "Bash(git status)",
    8. "Bash(git diff)"
    9. ],
    10. "deny": [
    11. "Read(./.env)",
    12. "Read(./secrets/**)",
    13. "Bash(rm -rf *)",
    14. "Bash(git push *)",
    15. "Bash(git reset --hard *)"
    16. ]
    17. },
    18. "sandbox": {
    19. "enabled": true,
    20. "networkAccess": false
    21. }
    22. }

    Minimum-permission checklist:

    • Allow reading only the project directory. Block .env, key files, and certificate directories.
    • Use a command allowlist that permits only tests, static checks, and read-only Git commands.
    • Deny deletion, push, deployment, and permission-changing commands by default. These should be executed manually when needed.
    • Disable network access by default. Enable it only when necessary and turn it off afterward.

    Validation method: Place a fake .env file in a temporary directory and ask the AI to read it. If access is denied, the rule is working. Then ask the AI to run git push; it should also be denied. Proceed only after both tests pass.

    A common mistake is writing secrets into project configuration and committing it. If this happens, rotate the secrets immediately, because deleting the commit history does not invalidate an exposed secret.

    2. Context Memory: Keep Files Short and Verify Indexes

    AI tools can lose constraints in large projects. Project memory files, session compaction, and code indexes are three common approaches, each with its own conditions for use.

    1. Project Memory File (e.g., AI_CONTEXT.md)

    Maintain a short instruction file in the repository root. Include only information that changes infrequently and must be known by the AI:

    1. # AI_CONTEXT.md
    2. ## Project Overview
    3. One sentence describing what the system does.
    4. ## Directory Responsibilities
    5. - src/api: HTTP interface layer, no business logic
    6. - src/service: Business logic
    7. - tests: Unit tests, using pytest
    8. ## Dependencies and Versions
    9. - Python 3.11; dependencies are listed in pyproject.toml
    10. ## Coding Standards
    11. - Public functions must have type annotations
    12. - Secrets must not be hardcoded in code
    13. ## Common Commands
    14. - Test: pytest -q
    15. - Check: ruff check .

    Boundary condition: Once the file exceeds roughly 200 lines, the AI is more likely to miss details. Shorten or split it. Do not put temporary task progress in this file; that belongs in task records.

    2. Session Compaction (e.g., commands such as /compact)

    Many session-based tools provide compaction commands, but names and behavior vary by version. Before compaction, ask the AI to output a decision checklist covering completed work, open questions, and key constraints, and save it to a file. After compaction, ask a question about a known constraint to confirm that the AI still remembers it.

    A common mistake is to continue immediately after compaction. As a result, the AI forgets a previously agreed API signature and starts rewriting a module that was already stable.

    3. Vector Index

    Introduce a vector index only when the codebase is large enough that memory files cannot cover the full picture. The index must be rebuilt as files change, and a matched snippet does not equal the correct answer.

    Validation method: Prepare 20 fixed questions and label the files that each question should match. Run them with and without the index, then compare hit rates. Keep the index only if the data shows it actually improves the hit rate. Do not claim greater accuracy without measurement.

    3. Skills and Subagents: Define Inputs and Outputs Clearly

    Skills

    A skill is an operating instruction that fixes a repeatable process. A skill should contain at least three parts: a trigger description (when to use it), execution steps, and acceptance criteria.

    For example, an “update API documentation” skill can be organized as follows:

    1. .ai/skills/update-api-docs/
    2. ├── README.md # Trigger description, steps, acceptance criteria
    3. ├── templates/ # Documentation output templates
    4. └── scripts/ # Optional helper scripts

    Use the directory and file names required by your tool. The key is to write concrete steps, such as “read all route decorators under src/api, generate a table, and run scripts/check_docs.py for validation.”

    Subagents

    Subagents are suitable for splitting large tasks, but each subagent must have clear inputs, outputs, and completion conditions. Below is a contract example for a refactoring task:

    Subagent Input Output Completion Condition
    Search Old API name List of call sites (file and line number) List matches grep results
    Test New API signature Unit test file Tests run and cover three types of exceptions
    Summary Outputs from the first two Merged diff and explanation All tests pass

    Common mistakes: the modification scope is not limited, so a subagent changes unrelated files; output formats are inconsistent, so the summary agent cannot parse them. The solution is to have each subagent modify only its assigned files and require a unified output structure.

    4. Hooks and Pipelines: Failures Must Block

    Pre-Commit Hook

    The following example uses a native Git hook to run static checks and tests before committing:

    1. #!/usr/bin/env bash
    2. # .git/hooks/pre-commit
    3. set -euo pipefail
    4. ruff check . || { echo "Lint failed; commit blocked"; exit 1; }
    5. pytest -q || { echo "Tests failed; commit blocked"; exit 1; }

    Set the executable permission:

    1. chmod +x .git/hooks/pre-commit

    Key points:

    • The hook blocks a commit through a non-zero exit code, so it must return a non-zero value on failure.
    • Commits triggered by AI must also pass through the same hook. Do not use --no-verify to bypass checks just so the AI can commit.
    • Write hook output to a logs/ directory for later traceability.

    Validation method: Intentionally commit a line of incorrectly formatted code, confirm that the commit is blocked, and then fix it.

    Rollback

    Whenever possible, make AI changes on a separate branch. For rollback, use git revert to create a reverse commit and preserve history. Avoid using git reset --hard directly, because it loses uncommitted changes and generally requires manual confirmation.

    Scheduled Scans

    You can configure a nightly CI job to run dependency vulnerability scanning, such as pip-audit, and generate a report. The job should only output the report; it should not automatically modify dependencies or merge code. A human reviews the report before taking action.

    Custom Slash Command: /review-pr

    Save a common review process as a template so that every invocation produces output with the same structure:

    1. You are a senior backend engineer. Review the diff of the current branch against main.
    2. Output format:
    3. 1. Conclusion: mergeable / needs changes / blocked
    4. 2. Issue list: file, line number, severity (high/medium/low), reason, recommendation
    5. 3. Uncovered test scenarios
    6. 4. Uncertainties: list items that require human confirmation
    7. Constraints:
    8. - Read-only; do not modify any files
    9. - When uncertain, state it explicitly; do not fabricate line numbers

    A common mistake is asking the model to review the entire repository, which leads to generic output. Limit the scope to the diff of the current branch.

    5. External Protocol Integration: Define Permissions Before Connecting Systems

    Model Context Protocol (MCP) is an open protocol that lets AI tools connect to external data sources and tools. Refer to the official specification for the specific version and configuration method. Before integration, answer three questions: Who can access this system? What operations can the AI perform? Could call results expose sensitive information?

    Integration checklist:

    • Least privilege: Expose read-only queries only. Write operations require separate approval and must not be executed directly by the AI.
    • Redaction: Before returning logs and database results to the model, filter fields such as phone numbers, ID numbers, and tokens.
    • Audit: Record the time, caller, parameter summary, and number of returned rows for each call.
    • Rate limiting and truncation: Set an upper limit on rows returned per call, such as 500 rows. For anything beyond that, return only summary statistics.
    • Credential management: Use environment variables or a secrets management service. Do not write credentials into configuration files.

    Self-Hosted Services

    If you need to write a context service for internal systems, prefer a strongly typed language and return structured fields instead of large blocks of raw text. Tool descriptions must clearly state purpose and parameter meanings; otherwise, the model may call them incorrectly.

    There are two common mistakes: returning an entire table at once and filling the context window; and vague tool descriptions that cause the model to use a query tool as a write tool.

    6. TDD and Multi-Agent Git Workflows

    TDD Process

    1. Write requirements and acceptance conditions into a file.
    2. Ask the AI to write only tests first, covering normal, boundary, and exception scenarios, without writing the implementation.
    3. Run the tests and confirm that all new tests fail. If a test passes before implementation, it is meaningless and must be rewritten.
    4. Ask the AI to implement the feature. Allow modifications only under src/ and do not allow changes to tests.
    5. Iterate until all tests pass, then refactor.

    Example prompt template:

    1. Task: Write pytest tests for parse_price(text).
    2. Requirements: Cover four scenarios: empty string, numbers with thousands separators, negative numbers, and invalid characters.
    3. Create only tests/test_parse_price.py and do not modify other files.
    4. Run pytest and report the results. All tests are expected to fail at this stage.

    Multi-Agent Git Workflow

    When multiple agents work in parallel, use git worktree to isolate their working directories:

    1. git worktree add ../proj-api-agent -b feat/api-agent main
    2. git worktree add ../proj-review-agent -b review/api main

    Each agent modifies files only in its own worktree. The main agent merges results in the main working directory:

    1. git merge --no-ff feat/api-agent

    Clean up worktrees after the task ends:

    1. git worktree remove ../proj-api-agent
    2. git worktree prune

    Common failure scenarios:

    • Merge conflicts: Two agents modify the same dependency file. The solution is to divide tasks by file and avoid cross-modification.
    • Cheating passes: An agent modifies tests to make them pass instead of fixing the implementation. The remedy starts with the prompt.