Command-Line AI Tools in Practice: MCP, Skills, and Multi-Model Configuration

    This article is for developers who are comfortable with the terminal, Git, and CI pipelines. It walks through installing a command-line AI tool in a test repository, connecting an MCP service, writing skill templates, and configuring multiple models, with verification and rollback checks at each step. It also covers permission safeguards, MCP troubleshooting, skill triggers, model routing, and a security and rollback checklist. Command names and configuration fields should follow the official documentation for the tool in use. The article does not cover vendor purchase processes.

    This article is for developers who are familiar with the terminal, Git, and CI pipelines. After reading it, you should be able to install the tool in a test repository, connect an MCP service, write skill templates, and configure multiple models, while knowing how to verify and roll back each step.

    The article does not cover vendor-specific purchase processes. Command names and configuration fields should follow the official documentation for the tool you use. If the project has no version control, or cannot be run in a test environment, address those two prerequisites first.

    1. Installation and Permission Confirmation

    Start in a test repository with Git history. Version control is the basis for rollback; without it, it is difficult to see which files the tool has changed.

    1. # Check the runtime environment; version requirements depend on the tool documentation
    2. git --version
    3. node --version # If the tool is distributed via Node.js
    4. <tool-cli> --version # Replace with the actual command name
    5. # Enter the test repository and confirm the working tree is clean
    6. cd ~/projects/demo-service
    7. git status

    On first launch, choose a permission mode that requires manual confirmation: confirm before every Shell command execution and file write. Once this is stable, add low-risk commands to the allowlist, such as mvn -q test or npm run lint. The following commands should not be added to the allowlist: rm, git push, kubectl apply, and any script that connects to a production environment.

    Verification step: ask the tool to add a comment line to a file, then run git diff and confirm that only the expected file was modified. If you need to undo the change, run git restore <file-path> on that file. This command discards all uncommitted changes in that file, including your own edits, so use it only for the file changed in this step.

    Troubleshooting checklist

    • Command not found: check whether the installation path is in PATH, then reopen the terminal.
    • File write denied: check whether the current user has write permission on the project directory; do not use sudo to bypass it.
    • Insufficient Shell command permission: confirm that the allowlisted command matches the full command string actually executed. Different arguments are usually treated as a new command by the tool.

    2. MCP Service Configuration and Troubleshooting

    MCP (Model Context Protocol) lets the tool call external resources through a standard interface. This section uses a read-only database as an example. The configuration file is usually located in the project root or the user directory; file names and field names vary by tool. The fields below are illustrative only.

    1. {
    2. "mcpServers": {
    3. "dev-db-readonly": {
    4. "command": "npx",
    5. "args": ["-y", "your-org/mysql-mcp-server"],
    6. "env": {
    7. "DB_HOST": "127.0.0.1",
    8. "DB_PORT": "3306",
    9. "DB_USER": "readonly_dev",
    10. "DB_PASSWORD": "${DEV_DB_PASSWORD}"
    11. },
    12. "allowedTools": ["list_tables", "describe_table", "select_query"]
    13. }
    14. }
    15. }

    Field descriptions:

    • command and args specify how the service process is started. your-org/mysql-mcp-server is a placeholder and must be replaced with a service package you have selected and reviewed.
    • The database account readonly_dev is granted only SELECT and metadata query permissions, and points only to the test database.
    • DB_PASSWORD is read from an environment variable; the password itself is not written into the configuration file. If the tool does not expand environment variables, use the secret reference method it supports instead. Do not write plaintext passwords into the file.
    • allowedTools restricts the operations the tool can call. No write or delete operations are configured, so even if the model misjudges, it cannot modify data.

    Verification step: restart the tool session, list the available MCP tools, and request the structure of a table. If the returned fields match the DESCRIBE result in the database, the connection is working.

    Troubleshooting checklist

    • MCP connection fails: run the command composed of command and args directly in the terminal and confirm that the service starts normally. Common causes are an outdated Node.js version or an incorrect package name.
    • Tool does not appear in the list: check the configuration file path and JSON syntax. One extra comma in JSON can cause the entire file to fail to load.
    • Tool returns a timeout: confirm that the database address is reachable from the local machine, and adjust timeout parameters according to the tool documentation if necessary.
    • Empty results are returned: confirm that the account has read permission on the target database, and verify that the database name points to the test database.

    3. Custom Skill Templates and Triggers

    A skill is a set of reusable instructions that tell the tool about the project’s coding standards and workflow. It is recommended to place skill files inside the repository and include them in version control so team members use the same rules.

    Directory structure example:

    1. demo-service/
    2. └── .ai-skills/
    3. ├── java-code-style/
    4. │ └── SKILL.md
    5. └── unit-test-gen/
    6. └── SKILL.md

    Below is a template for a unit test generation skill:

    1. ---
    2. name: unit-test-gen
    3. description: Generate JUnit 5 unit tests for the specified Service class, using Mockito to mock external dependencies
    4. triggers:
    5. - "generate unit tests"
    6. - "add tests for *"
    7. ---
    8. ## Scope
    9. - Only handle Service and Util classes under src/main/java.
    10. - Place test files in the corresponding package path under src/test/java.
    11. ## Steps
    12. 1. Read the public methods and exception branches of the target class.
    13. 2. Create an @Mock field for each external dependency; do not access a real database or network.
    14. 3. Include at least one normal path and one exception path for each public method.
    15. 4. After generation, run `mvn -q test -Dtest=<ClassName>Test`. If it fails, fix the test; do not modify the code under test.
    16. ## Prohibitions
    17. - Do not modify the business logic of production code.
    18. - Do not delete existing tests.

    The triggers field lists trigger phrases; the exact matching rules are determined by the tool implementation. Scope and Prohibitions limit the impact of the skill. It is recommended that every skill include these two sections.

    Verification step: enter “Generate unit tests for UserService” in the session and observe whether the tool reads the unit-test-gen skill. Then run mvn -q test -Dtest=UserServiceTest and confirm that the tests pass.

    Troubleshooting checklist

    • Skill is not triggered: check the indentation and quotes in the frontmatter, and confirm that the skill file is in the path required by the tool. If the tool provides session logs, check whether the skill was loaded.
    • Generated tests cannot compile: check whether JUnit 5 and Mockito dependencies are declared in pom.xml, and verify the versions.
    • Skill conflicts with team standards: the team’s code style document takes precedence. Revise the skill file and review it again.

    4. Multi-Model Configuration and Routing

    Models determine reasoning quality, response speed, and cost. Assigning different types of tasks to different models can help control cost, but routing rules need to be verified in practice. The configuration below separates lightweight tasks from complex tasks.

    1. profiles:
    2. fast:
    3. base_url: https://llm-gateway.internal.example.com/v1
    4. model: small-fast-model
    5. temperature: 0.2
    6. max_tokens: 1024
    7. api_key_ref: vault://ai/gateway-key
    8. deep:
    9. base_url: https://llm-gateway.internal.example.com/v1
    10. model: large-reasoning-model
    11. temperature: 0.3
    12. max_tokens: 8192
    13. api_key_ref: vault://ai/gateway-key
    14. routing:
    15. - match: "complete|comment|format|rename"
    16. profile: fast
    17. - match: "architecture|global refactor|cross-module"
    18. profile: deep
    19. - default: fast

    Parameter descriptions:

    • base_url points to the internal gateway or model provider address. For internal enterprise deployments, confirm that the gateway supports the interface format used by the tool, such as an OpenAI-compatible format.
    • api_key_ref stores only a reference to the secret; the actual key is injected by the secret management service. Do not write keys into source code, configuration commit history, or Shell history. If a key has leaked, rotate it on the server side immediately.
    • Lowering temperature makes output more stable, which is suitable for refactoring and code generation. However, it does not guarantee correct output; all changes still need to be verified by tests.
    • max_tokens limits the length of a single output. If it is set too small, generation results for large files will be truncated.

    Proxy settings: if the local machine accesses the external network through a corporate proxy, set HTTPS_PROXY and add the internal gateway domain to NO_PROXY. Otherwise, internal requests will also go through the proxy and fail to connect.

    Connectivity verification:

    1. curl -sS -m 10 https://llm-gateway.internal.example.com/v1/models \
    2. -H "Authorization: Bearer $(cat /run/secrets/ai_gateway_key)"

    If a model list is returned, the endpoint and authentication are working. If the secret file path is different in your environment, replace it with the corresponding read method.

    Routing verification: tools usually support viewing the model used for a single request. Run two test tasks, “complete comments” and “cross-module refactor”, and confirm that they hit fast and deep respectively. Keyword matching is coarse; when misjudgments occur, adjust the match rules instead of relying on the model to judge task cost by itself.

    Troubleshooting checklist

    • Model endpoint unreachable: first use the curl command above to check DNS, proxy, and certificates step by step. A common cause is that NO_PROXY is missing the internal domain.
    • Authentication failure (401 or 403): check whether the key has expired and whether the key has permission to call the target model.
    • Returned content is truncated: increase max_tokens, or split large tasks into multiple file-level tasks.
    • Routing result does not match expectations: check the actual profile in the session logs and compare it against the routing rules one by one.

    5. Security and Rollback Checklist

    Command-line tools can read files, execute commands, and access external services. Risk comes from these three capabilities. Check each item before rollout:

    1. Least privilege: the system account used to run the tool does not hold access credentials for the production environment.
    2. Read-only first: external data sources such as databases, cloud logs, and monitoring should be connected in read-only mode first; write-capable tools should be disabled by default.
    3. Command allowlist: allow only test, build, and format-check commands. Deletion, push, and deployment commands require manual confirmation each time.
    4. Audit logs: retain session logs and Git commit records so that every change can be traced to who initiated it and when.
    5. Production isolation: production configurations should not be placed in directories readable by the tool. Use temporary tokens with limited permissions in CI.
    6. Human review: submit tool-generated changes as branches or patches, and merge only after code review.

    Rollback methods:

    • Before large-scale changes, create a separate branch: git switch -c ai-refactor-<date>.
    • If the changes do not meet expectations, simply do not merge the branch; the main branch is unaffected.
    • For changes that have already been merged, use git revert <commit-hash> to create a reverse commit. This does not rewrite shared history.
    • Do not run git reset --hard or force push on shared branches; these operations overwrite other people’s work.

    CI integration recommendation: run the tool in an independent pipeline task and output patch files or review comments instead of pushing directly to the main branch. When the build fails, the developer decides whether to accept the fix result.

    6. Summary and Next Steps

    With permissions, auditing, and rollback measures in place, command-line AI tools can reduce switching between the editor, browser, and terminal. Actual benefits depend on project size, test coverage, and the selected model. It is recommended to pilot the tool in a low-risk repository first, record the change adoption rate and rework count over a period of time, and then decide whether to expand its use.