open · project · code — simplified
Project description
opcd
__ ___
/ /__ _ __ ___ __| \ \
| / _ \| '_ \ / __/ _` || |
< < (_) | |_) | (_| (_| | > >
| \___/| .__/ \___\__,_|| |
\_\ |_| /_/
open · project · code
Reusable Dev Containers for any project — without modifying the repository.
Table of Contents
Background
opcd is a CLI that opens any project in VS Code Dev Containers using reusable, local templates.
Define your environment once and reuse it across projects.
Typical Dev Container workflows involve:
- Copying
.devcontainer/directories between projects - Recreating environments repeatedly
- Committing configuration to repositories you do not control
opcd separates environment configuration from project code:
- Templates are stored locally
- Projects remain unchanged
- Containers are launched with a single command
Install
Dependencies
- VS Code with the Dev Containers extension
- Docker
- devcontainer CLI
pip install opcd
Usage
# Open a project (auto-detects template from container history, or uses default)
opcd open ~/projects/my-app
# Open with an explicit template
opcd open ~/projects/my-app opcd
Typical Workflow
opcd template new python-dev
opcd template edit python-dev
opcd open ~/projects/my-app python-dev
Project Switching
opcd list -a -i
Lists containers and allows reopening projects interactively.
Advanced Options
- Multiple template directories
- Verbose debugging (
-v) - Dry runs (
--dry-run) - Custom container paths
Internal Flow
- Validate project path (must exist)
- Resolve template (explicit → container history → settings default)
- Launch VS Code Dev Container
- Apply file injection rules
Configuration
opcd reads settings.json from:
~/.config/opcd/settings.json
Override the config directory:
OPCD_CONF_DIR=/custom/path opcd open ~/projects/my-app
The file is created automatically with defaults on first run.
settings.json
{
"template_sources": ["~/.local/share/opcd/templates"],
"default_template": "opcd",
"template_write_dir": null
}
| Key | Description |
|---|---|
template_sources |
Ordered list of template directories searched when resolving templates. |
default_template |
Template used when opcd open is called without a template argument and no container history is found. Error if unset. |
template_write_dir |
Directory where opcd template new writes new templates. null (default) uses the XDG data home: ~/.local/share/opcd/templates. Overridden per-invocation by --path. |
Template System
Default Location
~/.local/share/opcd/templates/
Configure additional paths via template_sources in settings.json (see Configuration).
File Injection
Inject files from the host into the container at startup.
Example
{
"customizations": {
"opcd": {
"cp": [
{
"source": "${localEnv:HOME}/.config/myapp",
"target": "/home/vscode/.config/myapp"
}
]
}
}
}
Fields
| Field | Required | Description |
|---|---|---|
source |
Yes | Host path |
target |
Yes | Container path |
override |
No | Skip if target exists (default: false) |
owner |
No | Requires group |
group |
No | Requires owner |
permissions |
No | chmod applied recursively |
Source Behavior
- Supports
${localEnv:VAR} - Supports relative paths from
.devcontainer/ - Missing environment variables cause the entry to be skipped
Copy Directory Contents
Use /. suffix:
{
"source": "${localEnv:HOME}/.config/myapp/.",
"target": "/home/vscode/.config/myapp/"
}
Copies directory contents instead of the directory itself.
Behavior Rules
target/copies into the directory- Without trailing
/copies as a file or directory override=falseskips existing files- Ownership and permissions are applied after copying
API
Full reference for all opcd commands and flags.
Global Flags
-v, --verbose Enable debug output
--version Show version and exit
opcd open
opcd open <path> [template] [options]
Open a project in VS Code using a devcontainer template.
Arguments
<path>— Project directory (must exist)[template](optional) — Template name, path to adevcontainer.json, or path to a directory containing it. Paths must start with./,../,/, or~/. If omitted, opcd resolves in this order:- Most recently running container for this project path
- Most recently stopped container for this project path
default_templatefromsettings.json(error if not set)
Options
| Option | Default | Description |
|---|---|---|
--dry-run |
— | Print resolved configuration and actions without executing |
--container-folder <path> |
resolved from devcontainer config | Container mount path |
--timeout <seconds> |
300 |
Time to wait for container startup |
opcd list
opcd list [-a] [-i]
List dev containers.
| Flag | Description |
|---|---|
-a, --all |
Include stopped containers |
-i, --interactive |
Prompt to reopen a listed container |
Interactive mode prompts Open [1-N]: — selecting a number reopens the project in VS Code.
opcd prune
opcd prune [path] [options]
Remove stopped dev containers. Either [path] or --all-projects is required.
Arguments
[path](optional) — Limit pruning to containers for this project directory.
Options
| Option | Description |
|---|---|
--all-projects |
Prune stopped containers across all projects |
--include-recent |
Also prune the most recently used container (skipped by default) |
opcd template
opcd template <subcommand>
Manage dev container templates.
opcd template new
opcd template new <name> [base] [options]
Create a new template by copying a base template.
| Argument | Default | Description |
|---|---|---|
[base] |
opcd |
Template to copy from |
| Option | Description |
|---|---|
--edit |
Launch the new template as a Dev Container in VS Code after creation |
--path <dir> |
Write the new template into <dir> instead of the configured write target |
opcd template edit
opcd template edit <template>
Open a template directory in VS Code for editing.
opcd template list
opcd template list [--long]
List available templates.
| Option | Description |
|---|---|
--long |
Show description and full path for each template |
opcd template default
opcd template default [name]
Get or set the default template.
- Without
name: prints the current default. - With
name: setsdefault_templateinsettings.json.
opcd template source
opcd template source <subcommand>
Manage template search paths stored in settings.json.
opcd template source list
opcd template source list
Print all configured template search paths, one per line.
opcd template source add
opcd template source add <path>
Append <path> to template_sources in settings.json. Prints a notice and exits cleanly if already present.
opcd template source remove
opcd template source remove <path>
Remove <path> from template_sources in settings.json. Exits with an error if not found.
opcd completion
opcd completion bash
opcd completion zsh
opcd completion fish
Print the shell completion setup command for the given shell.
Add to your shell rc file for persistent completion:
# bash (~/.bashrc)
eval "$(opcd completion bash)"
# zsh (~/.zshrc)
eval "$(opcd completion zsh)"
# fish (~/.config/fish/config.fish)
eval (opcd completion fish)
Contributing
Ask questions, report bugs, or request features in Issues.
PRs welcome. Open an issue first for significant changes.
Run tox (or pytest for a single-interpreter run) before submitting.
License
MIT © Nasser Alansari (dacrystal)
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opcd-0.4.0.tar.gz.
File metadata
- Download URL: opcd-0.4.0.tar.gz
- Upload date:
- Size: 433.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e21bb2602be3e8ae43926f98d153d44f63af23bc729219c1c729489c2c43466
|
|
| MD5 |
907fdbffef219e1cab895594d9f6ae01
|
|
| BLAKE2b-256 |
86f509bd6b4123b9e59d5fcd91d9c3e733d97d178d25cca4dc5b410ac6b30ff7
|
Provenance
The following attestation bundles were made for opcd-0.4.0.tar.gz:
Publisher:
publish-pypi.yml on dacrystal/opcd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opcd-0.4.0.tar.gz -
Subject digest:
6e21bb2602be3e8ae43926f98d153d44f63af23bc729219c1c729489c2c43466 - Sigstore transparency entry: 1373761881
- Sigstore integration time:
-
Permalink:
dacrystal/opcd@681fe1270c8be41554a7ddee5ead296028dfc216 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/dacrystal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@681fe1270c8be41554a7ddee5ead296028dfc216 -
Trigger Event:
push
-
Statement type:
File details
Details for the file opcd-0.4.0-py3-none-any.whl.
File metadata
- Download URL: opcd-0.4.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04fc3af47c861d6471fce29e98422249f0381fa691fb9f031a90420e7045e1c5
|
|
| MD5 |
aa112d7e3d7ae500d987a0c13839a329
|
|
| BLAKE2b-256 |
a4f3e82668ad4fa559287ed40dbcf56bda3aa50a960038be4a69f83541dc853c
|
Provenance
The following attestation bundles were made for opcd-0.4.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on dacrystal/opcd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opcd-0.4.0-py3-none-any.whl -
Subject digest:
04fc3af47c861d6471fce29e98422249f0381fa691fb9f031a90420e7045e1c5 - Sigstore transparency entry: 1373762017
- Sigstore integration time:
-
Permalink:
dacrystal/opcd@681fe1270c8be41554a7ddee5ead296028dfc216 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/dacrystal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@681fe1270c8be41554a7ddee5ead296028dfc216 -
Trigger Event:
push
-
Statement type: