[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79454C8C8DVS7QP4PRHJFTZ":3,"skill-same:01M79454C8C8DVS7QP4PRHJFTZ":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M79454C8C8DVS7QP4PRHJFTZ","oraclecloud-multi-env-setup",null,"Configure multi-environment OCI workflows with config profiles and compartment-per-environment patterns.\nUse when setting up dev\u002Fstaging\u002Fprod separation, switching between OCI profiles, or preventing accidental production deployments.\nTrigger with \"oraclecloud multi env setup\", \"oci profiles\", \"oci environments\", \"oci config profiles\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--oraclecloud-pack--oraclecloud-multi-env-setup\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: oraclecloud-multi-env-setup\ndescription: |\n  Configure multi-environment OCI workflows with config profiles and compartment-per-environment patterns.\n  Use when setting up dev\u002Fstaging\u002Fprod separation, switching between OCI profiles, or preventing accidental production deployments.\n  Trigger with \"oraclecloud multi env setup\", \"oci profiles\", \"oci environments\", \"oci config profiles\".\nallowed-tools: Read, Write, Edit, Bash(pip:*), Bash(oci:*), Grep\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ntags: [saas, oraclecloud, oci]\ncompatible-with: claude-code\n---\n\n# Oracle Cloud Multi-Environment Setup\n\n## Overview\n\nOCI has no \"accounts\" like AWS — you use compartments plus OCI config profiles for dev\u002Fstaging\u002Fprod separation. But profile switching is manual, compartment OCIDs are easy to confuse, and one wrong `--compartment-id` deploys to production. This skill sets up safe multi-environment workflows with named profiles, compartment aliasing, environment validation, and deployment guardrails.\n\n**Purpose:** Configure safe, repeatable multi-environment OCI workflows that prevent accidental cross-environment operations.\n\n## Prerequisites\n\n- **OCI Python SDK** — `pip install oci`\n- **OCI CLI** — installed and configured (`oci setup config`)\n- **Separate API keys per environment** (recommended) or a single key with cross-compartment policies\n- **Compartment OCIDs** for each environment (dev, staging, prod)\n- Python 3.8+\n\n## Instructions\n\n### Step 1: Configure Multi-Profile ~\u002F.oci\u002Fconfig\n\nThe OCI config file supports named profiles. Each profile can point to different tenancies, regions, or use different API keys:\n\n```ini\n# ~\u002F.oci\u002Fconfig\n\n[DEFAULT]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-ashburn-1\nkey_file=~\u002F.oci\u002Foci_api_key.pem\n\n[DEV]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-ashburn-1\nkey_file=~\u002F.oci\u002Foci_api_key_dev.pem\n\n[STAGING]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-phoenix-1\nkey_file=~\u002F.oci\u002Foci_api_key_staging.pem\n\n[PROD]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=ff:ee:dd:cc:bb:aa:00:99:88:77:66:55:44:33:22:11\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-ashburn-1\nkey_file=~\u002F.oci\u002Foci_api_key_prod.pem\n```\n\n**Best practice:** Use different API key pairs per environment. If the dev key is compromised, prod is unaffected.\n\n### Step 2: Create an Environment Configuration Module\n\nCentralize compartment OCIDs and profile mappings to prevent OCID confusion:\n\n```python\nimport oci\nimport os\n\n# Environment configuration — single source of truth for OCIDs\nENVIRONMENTS = {\n    \"dev\": {\n        \"profile\": \"DEV\",\n        \"compartment_id\": \"ocid1.compartment.oc1..dev_example\",\n        \"region\": \"us-ashburn-1\",\n        \"allow_destructive\": True,\n    },\n    \"staging\": {\n        \"profile\": \"STAGING\",\n        \"compartment_id\": \"ocid1.compartment.oc1..staging_example\",\n        \"region\": \"us-phoenix-1\",\n        \"allow_destructive\": True,\n    },\n    \"prod\": {\n        \"profile\": \"PROD\",\n        \"compartment_id\": \"ocid1.compartment.oc1..prod_example\",\n        \"region\": \"us-ashburn-1\",\n        \"allow_destructive\": False,  # Safety: block destructive ops\n    },\n}\n\ndef get_oci_config(env_name):\n    \"\"\"Load OCI config for the specified environment.\n\n    Validates the environment name and returns a configured\n    OCI config dict ready for client construction.\n    \"\"\"\n    if env_name not in ENVIRONMENTS:\n        raise ValueError(\n            f\"Unknown environment: {env_name}. \"\n            f\"Valid: {list(ENVIRONMENTS.keys())}\"\n        )\n\n    env = ENVIRONMENTS[env_name]\n    config = oci.config.from_file(\"~\u002F.oci\u002Fconfig\", profile_name=env[\"profile\"])\n    oci.config.validate_config(config)\n    return config, env\n\ndef get_compartment_id(env_name):\n    \"\"\"Get the compartment OCID for an environment.\"\"\"\n    return ENVIRONMENTS[env_name][\"compartment_id\"]\n\ndef is_destructive_allowed(env_name):\n    \"\"\"Check if destructive operations are allowed in this environment.\"\"\"\n    return ENVIRONMENTS[env_name][\"allow_destructive\"]\n```\n\n### Step 3: Build Safe Environment-Aware Clients\n\nWrap OCI clients with environment validation to prevent cross-environment mistakes:\n\n```python\nimport oci\nimport sys\n\nclass OCIEnvironment:\n    \"\"\"Environment-aware OCI client factory with safety guardrails.\"\"\"\n\n    def __init__(self, env_name):\n        self.env_name = env_name\n        self.config, self.env = get_oci_config(env_name)\n        self.compartment_id = self.env[\"compartment_id\"]\n\n        # Verify we can authenticate\n        identity = oci.identity.IdentityClient(self.config)\n        user = identity.get_user(self.config[\"user\"]).data\n        print(f\"[{env_name.upper()}] Authenticated as {user.name} \"\n              f\"in {self.config['region']}\")\n\n    def compute(self):\n        return oci.core.ComputeClient(self.config)\n\n    def network(self):\n        return oci.core.VirtualNetworkClient(self.config)\n\n    def storage(self):\n        return oci.object_storage.ObjectStorageClient(self.config)\n\n    def database(self):\n        return oci.database.DatabaseClient(self.config)\n\n    def safe_delete(self, operation, resource_name):\n        \"\"\"Execute a delete operation with environment safety checks.\"\"\"\n        if not is_destructive_allowed(self.env_name):\n            print(f\"BLOCKED: Destructive operation on {resource_name} \"\n                  f\"not allowed in {self.env_name.upper()}\")\n            print(\"Set allow_destructive=True in ENVIRONMENTS to override\")\n            sys.exit(1)\n\n        print(f\"WARNING: Deleting {resource_name} in {self.env_name.upper()}\")\n        return operation()\n\n# Usage\ndev = OCIEnvironment(\"dev\")\ninstances = dev.compute().list_instances(compartment_id=dev.compartment_id).data\nprint(f\"Dev instances: {len(instances)}\")\n\nprod = OCIEnvironment(\"prod\")\n# prod.safe_delete(...) would be blocked by allow_destructive=False\n```\n\n### Step 4: CLI Profile Switching\n\nUse profiles with the OCI CLI to target specific environments:\n\n```bash\n# List instances in dev\noci compute instance list --compartment-id ocid1.compartment.oc1..dev_example --profile DEV\n\n# List instances in prod (read-only)\noci compute instance list --compartment-id ocid1.compartment.oc1..prod_example --profile PROD\n\n# Set default profile via environment variable\nexport OCI_CLI_PROFILE=DEV\n\n# Override per-command\nOCI_CLI_PROFILE=PROD oci compute instance list --compartment-id ocid1.compartment.oc1..prod_example\n```\n\n**Shell aliases for safety:**\n\n```bash\n# Add to ~\u002F.bashrc or ~\u002F.zshrc\nalias oci-dev='OCI_CLI_PROFILE=DEV oci'\nalias oci-staging='OCI_CLI_PROFILE=STAGING oci'\nalias oci-prod='OCI_CLI_PROFILE=PROD oci'\n\n# Usage\noci-dev compute instance list --compartment-id ocid1.compartment.oc1..dev_example\noci-prod compute instance list --compartment-id ocid1.compartment.oc1..prod_example\n```\n\n### Step 5: Validate Config Before Operations\n\nAlways validate the config file and profile before running automation:\n\n```python\nimport oci\n\ndef validate_all_profiles():\n    \"\"\"Validate all OCI config profiles are properly configured.\"\"\"\n    profiles = [\"DEFAULT\", \"DEV\", \"STAGING\", \"PROD\"]\n    results = {}\n\n    for profile in profiles:\n        try:\n            config = oci.config.from_file(\"~\u002F.oci\u002Fconfig\", profile_name=profile)\n            oci.config.validate_config(config)\n\n            # Test authentication\n            identity = oci.identity.IdentityClient(config)\n            user = identity.get_user(config[\"user\"]).data\n            results[profile] = f\"OK — {user.name} in {config['region']}\"\n        except oci.exceptions.ConfigFileNotFound:\n            results[profile] = \"FAIL — config file not found\"\n        except oci.exceptions.ProfileNotFound:\n            results[profile] = \"FAIL — profile not found in config\"\n        except oci.exceptions.ServiceError as e:\n            results[profile] = f\"FAIL — {e.status}: {e.code}\"\n        except Exception as e:\n            results[profile] = f\"FAIL — {str(e)}\"\n\n    print(\"OCI Profile Validation:\")\n    for profile, status in results.items():\n        print(f\"  [{profile}] {status}\")\n\n    return all(\"OK\" in s for s in results.values())\n\nvalidate_all_profiles()\n```\n\n### Step 6: Environment Variables for CI\u002FCD\n\nFor CI\u002FCD pipelines where config files are impractical, use environment variables:\n\n```bash\n# Set OCI config via environment variables (CI\u002FCD pipelines)\nexport OCI_CLI_USER=\"ocid1.user.oc1..exampleuniqueID\"\nexport OCI_CLI_FINGERPRINT=\"aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99\"\nexport OCI_CLI_TENANCY=\"ocid1.tenancy.oc1..exampleuniqueID\"\nexport OCI_CLI_REGION=\"us-ashburn-1\"\nexport OCI_CLI_KEY_FILE=\"\u002Fpath\u002Fto\u002Fkey.pem\"\n# Or use key content directly:\nexport OCI_CLI_KEY_CONTENT=\"-----BEGIN RSA PRIVATE KEY-----\\n...\"\n```\n\n```python\nimport oci\n\n# Python SDK reads from environment when no config file exists\nconfig = oci.config.from_file()  # Falls back to env vars if ~\u002F.oci\u002Fconfig missing\n\n# Or construct config dict directly for CI\u002FCD\nconfig = {\n    \"user\": os.environ[\"OCI_CLI_USER\"],\n    \"fingerprint\": os.environ[\"OCI_CLI_FINGERPRINT\"],\n    \"tenancy\": os.environ[\"OCI_CLI_TENANCY\"],\n    \"region\": os.environ[\"OCI_CLI_REGION\"],\n    \"key_file\": os.environ[\"OCI_CLI_KEY_FILE\"],\n}\noci.config.validate_config(config)\n```\n\n## Output\n\nSuccessful completion produces:\n- A `~\u002F.oci\u002Fconfig` file with named profiles for each environment (DEV, STAGING, PROD)\n- An environment configuration module mapping profiles to compartment OCIDs\n- An environment-aware client factory with safety guardrails blocking destructive prod operations\n- Shell aliases for safe CLI profile switching\n- Validated authentication for all profiles\n\n## Error Handling\n\n| Error | Code | Cause | Solution |\n|-------|------|-------|----------|\n| ProfileNotFound | — | Wrong profile name in `from_file()` | Check `~\u002F.oci\u002Fconfig` profile names match exactly (case-sensitive) |\n| ConfigFileNotFound | — | Missing `~\u002F.oci\u002Fconfig` | Run `oci setup config` or create the file manually |\n| NotAuthenticated | 401 | Wrong key for the selected profile | Verify key_file path and fingerprint match the uploaded public key |\n| NotAuthorizedOrNotFound | 404 | Profile's user lacks access to target compartment | Add IAM policies for the user\u002Fgroup in the target compartment |\n| TooManyRequests | 429 | Rate limited | Back off; see `oraclecloud-rate-limits` |\n| InternalError | 500 | OCI service error | Retry after 30s; check https:\u002F\u002Focistatus.oraclecloud.com |\n\n**Critical mistake:** Using the DEFAULT profile's compartment OCID with the PROD profile's credentials (or vice versa). The environment config module in Step 2 prevents this by coupling profile names to compartment OCIDs.\n\n## Examples\n\n**Quick profile test from the command line:**\n\n```bash\n# Test all profiles in one shot\nfor profile in DEFAULT DEV STAGING PROD; do\n  echo -n \"[$profile] \"\n  oci iam user get --user-id \"$(oci iam user list --profile \"$profile\" --query 'data[0].id' --raw-output 2>\u002Fdev\u002Fnull)\" --profile \"$profile\" --query 'data.name' --raw-output 2>\u002Fdev\u002Fnull || echo \"FAILED\"\ndone\n```\n\n**Check which profile is active:**\n\n```python\nimport oci\nimport os\n\nprofile = os.environ.get(\"OCI_CLI_PROFILE\", \"DEFAULT\")\nconfig = oci.config.from_file(\"~\u002F.oci\u002Fconfig\", profile_name=profile)\nprint(f\"Active profile: {profile}\")\nprint(f\"Region: {config['region']}\")\nprint(f\"Tenancy: {config['tenancy']}\")\n```\n\n## Resources\n\n- [OCI Config File](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FAPI\u002FConcepts\u002Fsdkconfig.htm) — config file format and profile syntax\n- [CLI Environment Variables](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FAPI\u002FSDKDocs\u002Fclienvironmentvariables.htm) — OCI_CLI_* variables\n- [CLI Reference](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FAPI\u002FConcepts\u002Fcliconcepts.htm) — command-line interface guide\n- [Python SDK Reference](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002Ftools\u002Fpython\u002Flatest\u002F) — config loading and client construction\n- [Compartment Management](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FIdentity\u002FTasks\u002Fmanagingcompartments.htm) — organizing resources by environment\n\n## Next Steps\n\nAfter environments are configured, see `oraclecloud-enterprise-rbac` for compartment hierarchy design with least-privilege policies, or `oraclecloud-deploy-integration` for CI\u002FCD pipeline integration.\n","# Oracle Cloud Multi-Environment Setup\n\n## Overview\n\nOCI has no \"accounts\" like AWS — you use compartments plus OCI config profiles for dev\u002Fstaging\u002Fprod separation. But profile switching is manual, compartment OCIDs are easy to confuse, and one wrong `--compartment-id` deploys to production. This skill sets up safe multi-environment workflows with named profiles, compartment aliasing, environment validation, and deployment guardrails.\n\n**Purpose:** Configure safe, repeatable multi-environment OCI workflows that prevent accidental cross-environment operations.\n\n## Prerequisites\n\n- **OCI Python SDK** — `pip install oci`\n- **OCI CLI** — installed and configured (`oci setup config`)\n- **Separate API keys per environment** (recommended) or a single key with cross-compartment policies\n- **Compartment OCIDs** for each environment (dev, staging, prod)\n- Python 3.8+\n\n## Instructions\n\n### Step 1: Configure Multi-Profile ~\u002F.oci\u002Fconfig\n\nThe OCI config file supports named profiles. Each profile can point to different tenancies, regions, or use different API keys:\n\n```ini\n# ~\u002F.oci\u002Fconfig\n\n[DEFAULT]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-ashburn-1\nkey_file=~\u002F.oci\u002Foci_api_key.pem\n\n[DEV]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-ashburn-1\nkey_file=~\u002F.oci\u002Foci_api_key_dev.pem\n\n[STAGING]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-phoenix-1\nkey_file=~\u002F.oci\u002Foci_api_key_staging.pem\n\n[PROD]\nuser=ocid1.user.oc1..exampleuniqueID\nfingerprint=ff:ee:dd:cc:bb:aa:00:99:88:77:66:55:44:33:22:11\ntenancy=ocid1.tenancy.oc1..exampleuniqueID\nregion=us-ashburn-1\nkey_file=~\u002F.oci\u002Foci_api_key_prod.pem\n```\n\n**Best practice:** Use different API key pairs per environment. If the dev key is compromised, prod is unaffected.\n\n### Step 2: Create an Environment Configuration Module\n\nCentralize compartment OCIDs and profile mappings to prevent OCID confusion:\n\n```python\nimport oci\nimport os\n\n# Environment configuration — single source of truth for OCIDs\nENVIRONMENTS = {\n    \"dev\": {\n        \"profile\": \"DEV\",\n        \"compartment_id\": \"ocid1.compartment.oc1..dev_example\",\n        \"region\": \"us-ashburn-1\",\n        \"allow_destructive\": True,\n    },\n    \"staging\": {\n        \"profile\": \"STAGING\",\n        \"compartment_id\": \"ocid1.compartment.oc1..staging_example\",\n        \"region\": \"us-phoenix-1\",\n        \"allow_destructive\": True,\n    },\n    \"prod\": {\n        \"profile\": \"PROD\",\n        \"compartment_id\": \"ocid1.compartment.oc1..prod_example\",\n        \"region\": \"us-ashburn-1\",\n        \"allow_destructive\": False,  # Safety: block destructive ops\n    },\n}\n\ndef get_oci_config(env_name):\n    \"\"\"Load OCI config for the specified environment.\n\n    Validates the environment name and returns a configured\n    OCI config dict ready for client construction.\n    \"\"\"\n    if env_name not in ENVIRONMENTS:\n        raise ValueError(\n            f\"Unknown environment: {env_name}. \"\n            f\"Valid: {list(ENVIRONMENTS.keys())}\"\n        )\n\n    env = ENVIRONMENTS[env_name]\n    config = oci.config.from_file(\"~\u002F.oci\u002Fconfig\", profile_name=env[\"profile\"])\n    oci.config.validate_config(config)\n    return config, env\n\ndef get_compartment_id(env_name):\n    \"\"\"Get the compartment OCID for an environment.\"\"\"\n    return ENVIRONMENTS[env_name][\"compartment_id\"]\n\ndef is_destructive_allowed(env_name):\n    \"\"\"Check if destructive operations are allowed in this environment.\"\"\"\n    return ENVIRONMENTS[env_name][\"allow_destructive\"]\n```\n\n### Step 3: Build Safe Environment-Aware Clients\n\nWrap OCI clients with environment validation to prevent cross-environment mistakes:\n\n```python\nimport oci\nimport sys\n\nclass OCIEnvironment:\n    \"\"\"Environment-aware OCI client factory with safety guardrails.\"\"\"\n\n    def __init__(self, env_name):\n        self.env_name = env_name\n        self.config, self.env = get_oci_config(env_name)\n        self.compartment_id = self.env[\"compartment_id\"]\n\n        # Verify we can authenticate\n        identity = oci.identity.IdentityClient(self.config)\n        user = identity.get_user(self.config[\"user\"]).data\n        print(f\"[{env_name.upper()}] Authenticated as {user.name} \"\n              f\"in {self.config['region']}\")\n\n    def compute(self):\n        return oci.core.ComputeClient(self.config)\n\n    def network(self):\n        return oci.core.VirtualNetworkClient(self.config)\n\n    def storage(self):\n        return oci.object_storage.ObjectStorageClient(self.config)\n\n    def database(self):\n        return oci.database.DatabaseClient(self.config)\n\n    def safe_delete(self, operation, resource_name):\n        \"\"\"Execute a delete operation with environment safety checks.\"\"\"\n        if not is_destructive_allowed(self.env_name):\n            print(f\"BLOCKED: Destructive operation on {resource_name} \"\n                  f\"not allowed in {self.env_name.upper()}\")\n            print(\"Set allow_destructive=True in ENVIRONMENTS to override\")\n            sys.exit(1)\n\n        print(f\"WARNING: Deleting {resource_name} in {self.env_name.upper()}\")\n        return operation()\n\n# Usage\ndev = OCIEnvironment(\"dev\")\ninstances = dev.compute().list_instances(compartment_id=dev.compartment_id).data\nprint(f\"Dev instances: {len(instances)}\")\n\nprod = OCIEnvironment(\"prod\")\n# prod.safe_delete(...) would be blocked by allow_destructive=False\n```\n\n### Step 4: CLI Profile Switching\n\nUse profiles with the OCI CLI to target specific environments:\n\n```bash\n# List instances in dev\noci compute instance list --compartment-id ocid1.compartment.oc1..dev_example --profile DEV\n\n# List instances in prod (read-only)\noci compute instance list --compartment-id ocid1.compartment.oc1..prod_example --profile PROD\n\n# Set default profile via environment variable\nexport OCI_CLI_PROFILE=DEV\n\n# Override per-command\nOCI_CLI_PROFILE=PROD oci compute instance list --compartment-id ocid1.compartment.oc1..prod_example\n```\n\n**Shell aliases for safety:**\n\n```bash\n# Add to ~\u002F.bashrc or ~\u002F.zshrc\nalias oci-dev='OCI_CLI_PROFILE=DEV oci'\nalias oci-staging='OCI_CLI_PROFILE=STAGING oci'\nalias oci-prod='OCI_CLI_PROFILE=PROD oci'\n\n# Usage\noci-dev compute instance list --compartment-id ocid1.compartment.oc1..dev_example\noci-prod compute instance list --compartment-id ocid1.compartment.oc1..prod_example\n```\n\n### Step 5: Validate Config Before Operations\n\nAlways validate the config file and profile before running automation:\n\n```python\nimport oci\n\ndef validate_all_profiles():\n    \"\"\"Validate all OCI config profiles are properly configured.\"\"\"\n    profiles = [\"DEFAULT\", \"DEV\", \"STAGING\", \"PROD\"]\n    results = {}\n\n    for profile in profiles:\n        try:\n            config = oci.config.from_file(\"~\u002F.oci\u002Fconfig\", profile_name=profile)\n            oci.config.validate_config(config)\n\n            # Test authentication\n            identity = oci.identity.IdentityClient(config)\n            user = identity.get_user(config[\"user\"]).data\n            results[profile] = f\"OK — {user.name} in {config['region']}\"\n        except oci.exceptions.ConfigFileNotFound:\n            results[profile] = \"FAIL — config file not found\"\n        except oci.exceptions.ProfileNotFound:\n            results[profile] = \"FAIL — profile not found in config\"\n        except oci.exceptions.ServiceError as e:\n            results[profile] = f\"FAIL — {e.status}: {e.code}\"\n        except Exception as e:\n            results[profile] = f\"FAIL — {str(e)}\"\n\n    print(\"OCI Profile Validation:\")\n    for profile, status in results.items():\n        print(f\"  [{profile}] {status}\")\n\n    return all(\"OK\" in s for s in results.values())\n\nvalidate_all_profiles()\n```\n\n### Step 6: Environment Variables for CI\u002FCD\n\nFor CI\u002FCD pipelines where config files are impractical, use environment variables:\n\n```bash\n# Set OCI config via environment variables (CI\u002FCD pipelines)\nexport OCI_CLI_USER=\"ocid1.user.oc1..exampleuniqueID\"\nexport OCI_CLI_FINGERPRINT=\"aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99\"\nexport OCI_CLI_TENANCY=\"ocid1.tenancy.oc1..exampleuniqueID\"\nexport OCI_CLI_REGION=\"us-ashburn-1\"\nexport OCI_CLI_KEY_FILE=\"\u002Fpath\u002Fto\u002Fkey.pem\"\n# Or use key content directly:\nexport OCI_CLI_KEY_CONTENT=\"-----BEGIN RSA PRIVATE KEY-----\\n...\"\n```\n\n```python\nimport oci\n\n# Python SDK reads from environment when no config file exists\nconfig = oci.config.from_file()  # Falls back to env vars if ~\u002F.oci\u002Fconfig missing\n\n# Or construct config dict directly for CI\u002FCD\nconfig = {\n    \"user\": os.environ[\"OCI_CLI_USER\"],\n    \"fingerprint\": os.environ[\"OCI_CLI_FINGERPRINT\"],\n    \"tenancy\": os.environ[\"OCI_CLI_TENANCY\"],\n    \"region\": os.environ[\"OCI_CLI_REGION\"],\n    \"key_file\": os.environ[\"OCI_CLI_KEY_FILE\"],\n}\noci.config.validate_config(config)\n```\n\n## Output\n\nSuccessful completion produces:\n- A `~\u002F.oci\u002Fconfig` file with named profiles for each environment (DEV, STAGING, PROD)\n- An environment configuration module mapping profiles to compartment OCIDs\n- An environment-aware client factory with safety guardrails blocking destructive prod operations\n- Shell aliases for safe CLI profile switching\n- Validated authentication for all profiles\n\n## Error Handling\n\n| Error | Code | Cause | Solution |\n|-------|------|-------|----------|\n| ProfileNotFound | — | Wrong profile name in `from_file()` | Check `~\u002F.oci\u002Fconfig` profile names match exactly (case-sensitive) |\n| ConfigFileNotFound | — | Missing `~\u002F.oci\u002Fconfig` | Run `oci setup config` or create the file manually |\n| NotAuthenticated | 401 | Wrong key for the selected profile | Verify key_file path and fingerprint match the uploaded public key |\n| NotAuthorizedOrNotFound | 404 | Profile's user lacks access to target compartment | Add IAM policies for the user\u002Fgroup in the target compartment |\n| TooManyRequests | 429 | Rate limited | Back off; see `oraclecloud-rate-limits` |\n| InternalError | 500 | OCI service error | Retry after 30s; check https:\u002F\u002Focistatus.oraclecloud.com |\n\n**Critical mistake:** Using the DEFAULT profile's compartment OCID with the PROD profile's credentials (or vice versa). The environment config module in Step 2 prevents this by coupling profile names to compartment OCIDs.\n\n## Examples\n\n**Quick profile test from the command line:**\n\n```bash\n# Test all profiles in one shot\nfor profile in DEFAULT DEV STAGING PROD; do\n  echo -n \"[$profile] \"\n  oci iam user get --user-id \"$(oci iam user list --profile \"$profile\" --query 'data[0].id' --raw-output 2>\u002Fdev\u002Fnull)\" --profile \"$profile\" --query 'data.name' --raw-output 2>\u002Fdev\u002Fnull || echo \"FAILED\"\ndone\n```\n\n**Check which profile is active:**\n\n```python\nimport oci\nimport os\n\nprofile = os.environ.get(\"OCI_CLI_PROFILE\", \"DEFAULT\")\nconfig = oci.config.from_file(\"~\u002F.oci\u002Fconfig\", profile_name=profile)\nprint(f\"Active profile: {profile}\")\nprint(f\"Region: {config['region']}\")\nprint(f\"Tenancy: {config['tenancy']}\")\n```\n\n## Resources\n\n- [OCI Config File](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FAPI\u002FConcepts\u002Fsdkconfig.htm) — config file format and profile syntax\n- [CLI Environment Variables](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FAPI\u002FSDKDocs\u002Fclienvironmentvariables.htm) — OCI_CLI_* variables\n- [CLI Reference](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FAPI\u002FConcepts\u002Fcliconcepts.htm) — command-line interface guide\n- [Python SDK Reference](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002Ftools\u002Fpython\u002Flatest\u002F) — config loading and client construction\n- [Compartment Management](https:\u002F\u002Fdocs.oracle.com\u002Fen-us\u002Fiaas\u002FContent\u002FIdentity\u002FTasks\u002Fmanagingcompartments.htm) — organizing resources by environment\n\n## Next Steps\n\nAfter environments are configured, see `oraclecloud-enterprise-rbac` for compartment hierarchy design with least-privilege policies, or `oraclecloud-deploy-integration` for CI\u002FCD pipeline integration.\n",{"name":5,"tags":24,"author":28,"license":15,"version":29,"description":30,"allowed-tools":31,"compatible-with":32},[25,26,27],"saas","oraclecloud","oci","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Configure multi-environment OCI workflows with config profiles and compartment-per-environment patterns.\nUse when setting up dev\u002Fstaging\u002Fprod separation, switching between OCI profiles, or preventing accidental production deployments.\nTrigger with \"oraclecloud multi env setup\", \"oci profiles\", \"oci environments\", \"oci config profiles\".\n","Read, Write, Edit, Bash(pip:*), Bash(oci:*), Grep","claude-code","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--oraclecloud-pack--oraclecloud-multi-env-setup",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill oraclecloud-multi-env-setup",{"tool":48,"command":49},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill oraclecloud-multi-env-setup",{"tool":51,"command":52},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill oraclecloud-multi-env-setup","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--oraclecloud-pack--oraclecloud-multi-env-setup\u002FSKILL.md",true,[],[57,64,71,78,85,93],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":89,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]