A laptop on a wooden desk

Coding Securely in the Age of AI

I moved my development environments off my desktop.

After the ChainDrop incident, I asked myself how my development workflow should change. I reached two conclusions:

  • Agents can usually write and test code without credentials for external services. CI/CD can validate the change against those services.
  • My desktop has access to sensitive files, credentials, and accounts. Untrusted code on that desktop puts too much at risk.

These conclusions changed my desktop setup and improved my workflow.

How I Configure My Desktop / Laptop

I still use a Mac, but I may switch to Linux because most of my development now happens in the cloud. CI/CD or Xcode Cloud runs my builds, so I have less need for Xcode locally. My desktop setup is simple:

  • Safari: I use it for web access and email.
  • Brave: I use it for development with Claude, Codex, Cursor, GitHub, and similar tools.
  • Visual Studio Code: I review and edit code through GitHub Codespaces. The editor feels local, but the code runs in a separate cloud environment.
  • Password Manager: I keep it on my desktop and give coding agents no access to it.
  • Screen Recording App: The desktop app produces better video than the browser tools I tried.
  • Slack: I still use the desktop app because the web version felt slow, though I may try it again.
  • Cloud Drive: I still need it, even though it holds a lot of personal information. I keep development in a separate environment, which makes me more comfortable with cloud storage on my desktop.

That is about it. My desktop is simpler, and I am still as productive.

How I Configure AI

The Keyv repository shows how I configure my development environments for more secure development. It has settings in .cursor, .devcontainer, and .claude. I plan to add .codex as well.

I use Visual Studio Code with GitHub Codespaces for most of my Codex work. I prefer that workflow to the Codex Cloud interface. After I configure the Dev Container, I install the Codex extension and work directly in the cloud workspace.

I put this setup in my defense-in-depth skill. An AI agent can use it to configure the controls around its work. The skill covers Aikido Safe Chain for package installs and a seven-day dependency cooldown. It also pins GitHub Actions and container images, and limits CI permissions.

Connect your agent to my agentic MCP server. Ask it to apply defense-in-depth-nodejs to your repository. The skill checks the setup, applies one improvement per pull request, and records progress in DEFENSE_IN_DEPTH.md. Review each change before you merge its PR. Then tell the agent continue to start the next item.

The skill currently targets Node.js. I plan to add other languages as more of my work moves to Rust and TypeScript. I took the same approach with my dependency-management skill. That skill already supports Node.js, Rust, Python, Go, and .NET.

What My Agents Can Access

I keep credentials out of coding agents' prompts and development workspaces by default. That includes production environment files, service API keys, database passwords, and publishing tokens. The agent gets the code and the test setup it needs for the change.

If a task needs a token, I create a temporary one for a non-production service with a very short time to live (TTL). I revoke and delete it as soon as the PR ends, even if the token is still valid. I never give agents production tokens or GitHub access. I keep these permissions under my control. This preserves the checks and balances for code review, merges, and releases.

Validation starts inside that workspace. Agents can use mocks to test behavior, or start local services and load seeded test data. If a change needs a database or another service for tests, I ask the agent to set that up. Local in this case means inside the isolated development environment. The agent can exercise the application, reproduce failures, and test edge cases without a production connection.

CI/CD validates the change against real integrations from end to end. The credentials for those runs stay in CI/CD. Code in a CI job can use the secrets and permissions that the job receives. I review that code and the workflows that grant access. This is why workflow protection forms part of the setup.

I submit all agent-written code through the pull request process. The defense-in-depth checklist defines the controls for each step from the first dependency install to release:

  • Pull requests and required checks: The default branch requires a PR and the configured CI checks. Repository rules block direct pushes, force pushes, and branch deletion. The owner can bypass rules through the PR process. The baseline does not require an independent reviewer for every change.
  • Review of sensitive configuration: CODEOWNERS covers workflows, scripts, and the editor, agent, and Dev Container configuration. Repository rules require code-owner review for those paths, subject to the owner bypass. Public repositories also require maintainer approval before workflows run for outside contributors.
  • Dependency versions: The checklist requires a pinned package manager and a committed lockfile. CI installs dependencies with --frozen-lockfile. New package versions must be at least seven days old. This also applies to my own packages. If release timestamps are absent, the check fails.
  • Dependency execution and trust: The setup blocks dependency lifecycle scripts by default. Each exception needs an explicit review. pnpm also blocks exotic sources for transitive dependencies. Its trustPolicy: no-downgrade setting rejects versions with weaker evidence of publisher trust.
  • Checks during installation: Cloud development environments install packages through Aikido Safe Chain. Its bootstrap uses a pinned release and verifies the installer checksum. If setup fails, the bootstrap's stubs block standard package-manager commands. Socket Firewall checks CI installs that use its sfw wrapper. This site's Dockerfile installs use plain pnpm install, so Socket Firewall does not check those installs inside the image build.
  • Pinned build tools: The setup pins GitHub Actions to full commit SHAs and Dev Container images to digests. Repository rules limit which Actions can run. These references select specific action code and container images even if an upstream tag changes.
  • Limited workflow permissions: CI starts with read-only repository access. Only jobs that need extra permissions receive them. Checkouts that do not push retain no Git credentials. Jobs save generated output as artifacts. A job can write to the repository only if its purpose requires that access, such as a release job.
  • Workflow security checks: zizmor checks workflows on every PR for problems such as script injection, excessive permissions, and credential persistence. Workflows that run untrusted PR code do not use pull_request_target. The setup separates caches across trust boundaries. Workflows that publish artifacts disable package-manager caching. This reduces the risk that a poisoned cache reaches a privileged job.
  • Code and dependency scanning: Aikido scans every build for vulnerabilities, exposed secrets, and code issues. Socket checks dependency changes for suspicious behavior. Examples include new install scripts, network access, and obfuscated code. Secret scanning and push protection add repository checks where the platform supports them. The baseline disables Dependabot because Aikido and Socket provide these checks. Other dependency updaters can open PRs, but they cannot merge them automatically.

For npm libraries, the release workflow must pass an Aikido scan before it can stage a package. CI uses short-lived OIDC authentication that permits only staging. The workspace and CI secrets contain no npm publish token.

I use Drydock for a final check of the exact staged package before publication. Its report compares the package with the previous release and identifies suspicious changes. Examples include new install scripts or credential reads. After the review, a maintainer approves promotion in npm with 2FA.

Package settings require 2FA and disallow token-based publishing. Repository metadata links provenance to the correct project. Only repository admins can create tags. GitHub prevents changes to assets and tags for new immutable releases.

The checklist also covers account security. It requires passkeys or hardware keys for GitHub and npm, plus secure storage for recovery codes. Public repositories also use private vulnerability reporting.

A repository admin applies the final lockdown settings after the earlier controls are in place. Each repo records which controls are in place in DEFENSE_IN_DEPTH.md. Its public SECURITY.md describes the protections already in place.

Final Thoughts

I continue to improve this setup as new security incidents occur. It helps me stay productive and reduces my attack surface. I hope you can use these ideas to make your own development workflow more secure.

Previous
Keyv v6: Better Adapters, Encryption, and Browser Support
Next
RustBoy AI: Learning About Agents by Making a Movie