Skip to content

Commit 4b64821

Browse files
initial structure codacy guardrails docs (#2394)
Codacy Guardrails official documentation - version 1 Fix some terms using the tool vale
1 parent dd93670 commit 4b64821

35 files changed

Lines changed: 508 additions & 2 deletions

.github/styles/Microsoft/Terms.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ ignorecase: true
55
action:
66
name: replace
77
swap:
8-
'(?:agent|virtual assistant|intelligent personal assistant)': personal digital assistant
98
'(?:drive C:|drive C>|C: drive)': drive C
109
'(?:internet bot|web robot)s?': bot(s)
1110
'(?:microsoft cloud|the cloud)': cloud

.github/styles/Microsoft/Wordiness.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ swap:
7979
in lieu of: instead of
8080
in many cases: often
8181
in most cases: usually
82-
in order to: to
8382
in some cases: sometimes
8483
in spite of the fact that: although
8584
in spite of: despite

.github/styles/config/vocabularies/Codacy/accept.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
aligncheck
2+
autofix
3+
autoremediate
24
allowlist
35
Atlassian
46
autovacuum
@@ -41,6 +43,7 @@ Gradle
4143
Grafana
4244
Gravatar
4345
Hadolint
46+
Hardcoded
4447
hostname
4548
hotfix
4649
Jira
@@ -91,4 +94,6 @@ unassigns
9194
unfollow
9295
vacuumdb
9396
Visualforce
97+
VSCode
9498
Xcode
99+
webserver

.github/workflows/vale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
with:
1919
filter_mode: added
2020
debug: true
21+
fail_on_error: false
2122
env:
2223
# Required
2324
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ site/
1717

1818
# Auxiliary tool outputs
1919
tools/*.csv
20+
21+
.codacy
22+
23+
#Ignore vscode AI rules
24+
.github/copilot-instructions.md
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# FAQs
2+
3+
## How do I install Codacy Guardrails?
4+
Please have a look at our [documentation](codacy-guardrails-getting-started.md)
5+
6+
## Does Guardrails only work with AI-generated code?
7+
No. While Guardrails does scan and autofix AI code as part of the agent flow, it scans any code shown in your IDE in real-time, regardless of how it was written.
8+
9+
## How's Guardrails different from Codacy’s traditional analysis?
10+
Guardrails is IDE-first and real-time. It complements Codacy’s platform analysis by catching issues earlier in the development cycle.
11+
12+
## Does Guardrails work offline?
13+
Yes, local scanning via Codacy CLI works offline. API-based features (like querying metrics) require connectivity.
14+
15+
## Which AI security and quality standards can I enforce with Guardrails?
16+
Codacy Guardrails detects and autoremediate security risks and quality issues in JavaScript, TypeScript, Python, and Java, including:
17+
18+
19+
- SAST vulnerabilities
20+
- Hardcoded secrets
21+
- Insecure dependencies
22+
- Error prone code
23+
- Performance issues
24+
- Best practices
25+
- Complex code
26+
- Code duplications
27+
- Styling violations
28+
29+
Configuring and enforcing coding standards at scale across all IDEs in your organization requires a Codacy Team or Business subscription.
30+
31+
## Is my data secure?
32+
Codacy Guardrails isn't a large language model, but an IDE extension that uses an MCP Server to communicate with existing AI coding agents owned by the user.
33+
34+
## When I change some analysis configuration in the UI, is it automatically applied to Guardrails?
35+
We're still working on this feature but in order to update the new tool configuration. you should run the command in your repository:
36+
37+
``` bash
38+
codacy-cli init
39+
```
40+
41+
This way Codacy will run the latest configuration.
42+
43+
## Does guardrails generate code for me?
44+
Guardrails Specify that Guardrails itself doesn’t generated anything but we inform the AI agent where issues are located and scan generated code using the Codacy CLI.
45+
46+
## How much does Guardrails cost?
47+
Codacy Guardrails is a free IDE Extension for local scanning of AI-generated and human-written code, **available free of charge to all developers.**
48+
49+
Check our [Team and Organization plans](https://www.codacy.com/pricing) to unlock:
50+
51+
52+
- Central configuration and enforcement of AI coding standards across teams and projects
53+
- Query and autofix existing problems across your codebase from the AI chat panel
54+
- Generate custom security and code quality reports using AI prompts
55+
- Full access to the Codacy Cloud platform including:
56+
57+
- Pipeline-less AppSec and code quality scans
58+
- PR merge gates
59+
- Team dashboards
60+
- Security reports
61+
- DAST pipelines
62+
- Jira integration
63+
64+
## Does Guardrails work with all OS?
65+
Guardrails is supported on MacOS, Linux, and Windows (via [WSL](https://learn.microsoft.com/en-us/windows/wsl/install))
66+
67+
## Can I use Guardrails without an AI copilot?
68+
Codacy Guardrails is designed to be installed from our IDE extension for VS Code, Cursor and Windsurf. but as long as you have an AI code generator that's compatible with the MCP protocol you can also add Guardrails into your MCP configuration manually.
69+
70+
Without an AI coding agent, you instead need to use the Codacy IDE extension without the MCP Server.
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Getting Started
2+
3+
Codacy Guardrails is a brand new way of enforcing code security and quality standards for AI-generated code, built into the free Codacy IDE Extension for VSCode, Copilot, Cursor, and Windsurf. Guardrails help developers ship safer, cleaner AI code by applying best practices and blocking insecure patterns while the code is being generated.
4+
5+
Besides real-time AI code scanning, Guardrails users can now prompt all their Codacy findings, without ever leaving the AI chat panel inside their IDE.
6+
7+
**New to Codacy Guardrails?** [Check our blog post](https://blog.codacy.com/codacy-guardrails-free-real-time-enforcement-of-security-and-quality-standards)
8+
9+
<iframe width="560" height="315" src="https://www.youtube.com/embed/uVyRWnnJu-0?si=Pnbk65EvpvvJRXX4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
10+
11+
12+
## Prerequisites
13+
14+
- git
15+
- node.js - ensure the `npx` commands runs without issues
16+
17+
### Supported Operating Systems
18+
19+
- macOS
20+
- Linux
21+
- Windows (Coming Soon)
22+
23+
!!! important
24+
**For Windows users: Windows WSL** (a feature that allows you to run a Linux environment directly on Windows, without the need for a virtual machine or dual-boot setup) is the only way you can use this feature for now, but we're still working to fully support Windows.
25+
26+
27+
### Supported IDEs
28+
29+
- Visual Studio Code
30+
- Cursor
31+
- Windsurf
32+
33+
!!! note
34+
Visual Studio Code Insiders is recommended for its faster performance and compatibility with Codacy Guardrails. However, since it's a beta version, you may encounter occasional issues.
35+
36+
### Built-in Scanners
37+
38+
- Trivy
39+
- Semgrep
40+
- ESLint
41+
- Pylint
42+
- PMD
43+
- dartanalyzer
44+
- [Lizard](https://docs.codacy.com/release-notes/cloud/cloud-2025-02-adding-ruff-lizard/#lizard)
45+
46+
## How to install - Quick Guide
47+
48+
### 1. Download the extension
49+
50+
- [Visual Studio Code](https://tinyurl.com/codacy-vscode)
51+
- [Cursor](http://tinyurl.com/codacy-cursor)
52+
- [Windsurf](http://tinyurl.com/codacy-windsurf)
53+
54+
This will open the Codacy Extension in your IDE Marketplace. Click **Install**
55+
56+
![Install Extension](images/install-codacy-extension.png)
57+
58+
59+
### 2. Install and activate the Codacy CLI for local analysis
60+
61+
Click on the button **Install Codacy CLI**
62+
63+
![Install CLI](images/codacy-extension-activate-cli.png)
64+
65+
It will create a folder in your local repository called **.codacy** with all needed configuration:
66+
67+
- The configuration from all built-in scanners
68+
- Codacy CLI script to run analysis locally
69+
70+
!!! note
71+
If you don't want this folder to be part of your repository in future commits but continue working with it locally, please add **.codacy** to your .gitignore file
72+
73+
74+
### 3. Install MCP Server
75+
76+
#### a. Add the Codacy MCP Server
77+
78+
In the Codacy Extension tab, click **Add Codacy MCP Server**
79+
80+
![Add Codacy MCP Server](images/add-codacy-mcp-server.png)
81+
82+
#### b. Check if the Codacy MCP Server is enabled
83+
84+
On the left side menu of the Codacy extension, please make sure that MCP server is set up and ready.
85+
86+
![Codacy MCP Server is enabled](images/mcp-server-enabled.png)
87+
88+
### 4. Restart your IDE
89+
90+
91+
## How to install - Manually
92+
93+
### 1. Install and activate the Codacy CLI for local analysis {: id="install-cli"}
94+
95+
#### Download
96+
97+
##### MacOS (brew)
98+
99+
To install `codacy-cli` using Homebrew:
100+
101+
```bash
102+
brew install codacy/codacy-cli-v2/codacy-cli-v2
103+
```
104+
105+
##### Linux
106+
107+
For Linux, we rely on the **codacy-cli.sh** script in the root. To download the CLI, run:
108+
109+
```bash
110+
bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-cli-v2/main/codacy-cli.sh)
111+
```
112+
You can either put the downloaded script in a specific file or create an alias that will download the script and look for changes:
113+
114+
```bash
115+
alias codacy-cli="bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-cli-v2/main/codacy-cli.sh)"
116+
```
117+
118+
#### Installation
119+
120+
Before running the analysis, install the specified tools:
121+
122+
```bash
123+
codacy-cli install
124+
```
125+
126+
### 2. Install MCP Server {: id="install-mcp-server"}
127+
128+
If you want to use MCP Server with a NPM package you should download it from [here](https://www.npmjs.com/package/@codacy/codacy-mcp)
129+
130+
!!! important
131+
You can find some limitations using this approach because the AI doesn't automatically analyse the code generated unless there's a rule set for it to do so. When using the IDE extension (VS Code, Cursor, or Windsurf), we create those AI rules for the workspace, but if you are installing the MCP manually, you will need to create those rules by yourself. <a href="mailto:support@codacy.com">Let us know if you you plan to use this approach, so we can provide more information</a>
132+
133+
#### Setup
134+
135+
##### Cursor, Windsurf and Claude Desktop
136+
137+
Depending on what IDE you are connecting the MCP Server to, you can use the following methods:
138+
139+
- Cursor: edit the `.cursor/mcp.json` file to add the following
140+
- Windsurf: edit the `.codeium/windsurf/mcp_config.json` file to add the following
141+
- Claude Desktop: edit the `claude_desktop_config.json` file to add the following
142+
143+
```json
144+
{
145+
"mcpServers": {
146+
"codacy": {
147+
"command": "npx",
148+
"args": ["-y", "@codacy/codacy-mcp"],
149+
"env": {
150+
"CODACY_ACCOUNT_TOKEN": "<YOUR_TOKEN>",
151+
"CODACY_CLI_VERSION": "<VERSION>"
152+
}
153+
}
154+
}
155+
}
156+
```
157+
158+
##### VS Code with Copilot
159+
160+
For connecting the MCP Server to Copilot in VS Code, add the following to the global config of the IDE:
161+
162+
```json
163+
{
164+
"mcp": {
165+
"inputs": [],
166+
"servers": {
167+
"codacy": {
168+
"command": "npx",
169+
"args": ["-y", "@codacy/codacy-mcp"],
170+
"env": {
171+
"CODACY_ACCOUNT_TOKEN": "<YOUR_TOKEN>",
172+
"CODACY_CLI_VERSION": "<VERSION>"
173+
}
174+
}
175+
}
176+
}
177+
}
178+
```
179+
180+
You can open the user settings.json file in:
181+
182+
`View > Command Palette > Preferences: Open User Settings (JSON)`
183+
184+
Or open the general settings.json file directly, which according to your OS should be located in:
185+
186+
- for macOS: `~/Library/Application Support/Code/User/settings.json`
187+
- for Windows: `%APPDATA%\Code\User\settings.json`
188+
- for Linux: `~/.config/Code/User/settings.json`
189+
190+
![Settings.json in VSCode](images/settings-json-vscode.png)
191+
192+
Make sure you update the value of `CODACY_ACCOUNT_TOKEN` with your [API token](../codacy-api/api-tokens.md).
193+
194+
a. Above the MCP Server configuration in **Settings.json** file, you can Click in the command **Start**
195+
196+
![Start MCP Server in VSCode](images/start-mcp-server-vscode.png)
197+
198+
b. Make sure you have Agent mode enabled: [vscode://settings/chat.agent.enabled](vscode://settings/chat.agent.enabled)
199+
200+
c. Open the Copilot chat and switch the mode to `Agent`. You can check that the MCP server was enabled correctly by clicking on the `Select tools` icon, which should list all the available Codacy tools.
201+
202+
![Copilot Agent with Codacy tools](images/copilot_agent.png)

0 commit comments

Comments
 (0)