Linux command
cody 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Log in via web browser
cody auth login --web
Send a chat message
cody chat -m "[Explain React hooks]"
Ask about a local file
cody chat --context-file [src/app.ts] -m "[Are there code smells here?]"
Use a remote repository as context
cody chat --context-repo [github.com/owner/repo] -m "[question]"
Generate a commit message from git diff
git diff | cody chat --stdin -m "Write a commit message for this diff"
Check authentication status
cody auth whoami
说明
cody is the command-line interface for Sourcegraph's Cody AI coding assistant. It provides terminal access to the same AI technology that powers Cody's IDE extensions, enabling code understanding, generation, and analysis directly from the command line. The CLI supports contextual queries using local files via --context-file or remote repositories via --context-repo, allowing Cody to provide more accurate and relevant responses based on your codebase. Standard input integration enables powerful workflow automation. Pipe git diffs for commit messages, code output for analysis, or logs for debugging assistance. Multiple input methods can be combined in a single query. Authentication credentials are stored securely in the operating system's credential manager. Alternatively, use SRC_ENDPOINT and SRC_ACCESS_TOKEN environment variables for CI/CD pipelines or ephemeral environments.
参数
- -m, --message _text_
- Message to send to Cody.
- --context-file _path_
- Include a local file as context for the query.
- --context-repo _repository_
- Include a remote repository as context (e.g. github.com/owner/repo).
- --stdin
- Read input from standard input.
- --model _model_
- Specify LLM model (e.g. claude-3.5-sonnet).
- auth login --web
- Authenticate with Sourcegraph. Use --web for browser-based login.
- auth logout
- Sign out and remove stored access token.
- auth whoami
- Display current authentication status and account info.
- chat -m _message_
- Send a message to Cody AI assistant.
FAQ
What is the cody command used for?
cody is the command-line interface for Sourcegraph's Cody AI coding assistant. It provides terminal access to the same AI technology that powers Cody's IDE extensions, enabling code understanding, generation, and analysis directly from the command line. The CLI supports contextual queries using local files via --context-file or remote repositories via --context-repo, allowing Cody to provide more accurate and relevant responses based on your codebase. Standard input integration enables powerful workflow automation. Pipe git diffs for commit messages, code output for analysis, or logs for debugging assistance. Multiple input methods can be combined in a single query. Authentication credentials are stored securely in the operating system's credential manager. Alternatively, use SRC_ENDPOINT and SRC_ACCESS_TOKEN environment variables for CI/CD pipelines or ephemeral environments.
How do I run a basic cody example?
Run `cody auth login --web` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -m, --message _text_ do in cody?
Message to send to Cody.