diff --git a/src/ConfigurableStaticContextEnvironmentTrait.php b/src/ConfigurableStaticContextEnvironmentTrait.php
new file mode 100644
index 0000000..db23f06
--- /dev/null
+++ b/src/ConfigurableStaticContextEnvironmentTrait.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Drupal\ctools;
+
+trait ConfigurableStaticContextEnvironmentTrait {
+
+  /**
+   * Get static contexts configuration.
+   *
+   * @return array[]
+   *   A list of arrays with the keys name, label, type and value.
+   */
+  public function getStaticContexts() {
+    return $this->static_context;
+  }
+
+  /**
+   * Get a specific static context.
+   *
+   * @param $name
+   *   The context name.
+   *
+   * @return array
+   *   An array with keys name, label, type and value.
+   */
+  public function getStaticContext($name) {
+    if (isset($this->static_context[$name])) {
+      return $this->static_context[$name];
+    }
+    return [];
+  }
+
+  /**
+   * Build Static Context Values.
+   *
+   * @return \Drupal\Component\Plugin\Context\ContextInterface[]
+   *   An array of set context values, keyed by context name.
+   */
+  public function getStaticContextValues() {
+    return \Drupal::service('ctools.context_mapper')->getContextValues($this->getStaticContexts());
+  }
+
+}
diff --git a/src/ContextEnvironmentInterface.php b/src/ContextEnvironmentInterface.php
new file mode 100644
index 0000000..8c1a96e
--- /dev/null
+++ b/src/ContextEnvironmentInterface.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\ctools;
+
+/**
+ * Interface for context environments.
+ */
+interface ContextEnvironmentInterface {
+
+  /**
+   * Gets runtime context values for the given context IDs.
+   *
+   * @param string[] $context_ids
+   *   Unqualified context IDs relative to the environment.
+   *
+   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
+   *   The determined contexts, keyed by the unqualified id.
+   */
+  public function getRuntimeEnvironmentContexts(array $context_ids);
+
+  /**
+   * Gets all available contexts for the purposes of configuration.
+   *
+   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
+   *   All available contexts.
+   */
+  public function getAvailableEnvironmentContexts();
+}
diff --git a/src/ContextEnvironmentTrait.php b/src/ContextEnvironmentTrait.php
new file mode 100644
index 0000000..1dd4c4d
--- /dev/null
+++ b/src/ContextEnvironmentTrait.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Drupal\ctools;
+
+/**
+ * Trait for context environments.
+ */
+trait ContextEnvironmentTrait {
+
+  /**
+   * Get the runtime contexts for an environment for given context ids.
+   *
+   * @param string[] $context_ids
+   *   Unqualified context ids associated with this environment.
+   *
+   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
+   *   The determined contexts, keyed by the unqualified context id.
+   */
+  public function getRuntimeEnvironmentContexts(array $context_ids) {
+    $contexts = [];
+    if (is_callable([$this, 'getProvidedContextValues'])) {
+      $contexts += $this->getProvidedContextValues();
+    }
+    if (is_callable([$this, 'getStaticContextValues'])) {
+      $contexts += $this->getStaticContextValues();
+    }
+    // @todo: Collect from relationships.
+    return $contexts;
+  }
+
+  /**
+   * Gets all available contexts for the purposed of configuration.
+   *
+   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
+   *   All available contexts.
+   */
+  public function getAvailableEnvironmentContexts() {
+    $contexts = [];
+    if (is_callable([$this, 'getAvailableProvidedContexts'])) {
+      $contexts += $this->getAvailableProvidedContexts();
+    }
+    // Collect static context available contexts. Because these are static
+    // there's no harm in just loading them with values anyway.
+    if (is_callable([$this, 'getStaticContextValues'])) {
+      $contexts += $this->getStaticContextValues();
+    }
+    // @todo: Collect relationship info.
+    return $contexts;
+  }
+}
diff --git a/src/EnvironmentAwareContextRepository.php b/src/EnvironmentAwareContextRepository.php
new file mode 100644
index 0000000..be43577
--- /dev/null
+++ b/src/EnvironmentAwareContextRepository.php
@@ -0,0 +1,121 @@
+<?php
+
+namespace Drupal\ctools;
+
+use Drupal\Core\Plugin\Context\ContextRepositoryInterface;
+
+/**
+ * Provides a context repository that is aware of its environment.
+ *
+ * This works like a normal ContextRepository except that it can have an
+ * environment set. This environment can then add to the contexts available.
+ */
+class EnvironmentAwareContextRepository implements ContextRepositoryInterface {
+
+  /**
+   * An array of context environments.
+   *
+   * @var \Drupal\ctools\ContextEnvironmentInterface
+   */
+  protected $environments = [];
+
+  /**
+   * The statically cached contexts.
+   *
+   * @var \Drupal\Core\Plugin\Context\ContextInterface[]
+   */
+  protected $contexts = [];
+
+  /**
+   * Set the context environment.
+   *
+   * @param string name
+   *   Identifier for this environment.
+   * @param \Drupal\ctools\ContextEnvironmentInterface $environment;
+   *   The environment object to pull contexts from.
+   */
+  public function addContextEnvironment($name, ContextEnvironmentInterface $environment) {
+    $this->environments[$name] = $environment;
+  }
+
+  /**
+   * Get the context environment.
+   *
+   * @return \Drupal\ctools\ContextEnvironmentInterface
+   */
+  public function getContextEnvironment($name) {
+    return $this->environments[$name] ? : FALSE;
+  }
+
+  /**
+   * Get all available context environments.
+   *
+   * @return \Drupal\ctools\ContextEnvironmentInterface[]
+   */
+  public function getContextEnvironments() {
+    return $this->environments;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRuntimeContexts(array $context_ids) {
+    $contexts = [];
+
+    // Any contexts passed in without an '@env' at the beginning get passed off
+    // to the global context provider. Contexts with '@env' should be of the
+    // form '@env:{environment_name}:{unqualified_context_id}' this allows the
+    // context repository to locate the correct context.
+    $global_context_ids = $environment_context_ids = [];
+    foreach ($context_ids as $id) {
+      if (isset($this->contexts[$id])) {
+        $contexts[$id] = $this->contexts[$id];
+        continue;
+      }
+
+      if (($id[0] === '@') && (strpos($id, ':') !== FALSE) && (substr($id, 0, 4) != '@env')) {
+        $global_context_ids[] = $id;
+      }
+      else if (substr($id, 0, 4) == '@env') {
+        $environmental_context_ids[] = substr($id, 4);
+      }
+    }
+
+    foreach (\Drupal::service('context.repository')->getRuntimeContexts($global_context_ids) as $id => $context) {
+      $this->contexts[$id] = $contexts[$id] = $context;
+    }
+
+    $context_ids_by_environment = [];
+    foreach ($environmental_context_ids as $id) {
+      list($environment_name, $context_id) = explode(':', $id, 2);
+      $context_ids_by_environment[$environment_name][] = $context_id;
+    }
+
+    foreach ($context_ids_by_environment as $environment_name => $ids) {
+      if ($this->getContextEnvironment($environment_name)) {
+        foreach ($this->getContextEnvironment($environment_name)->getRuntimeEnvironmentContexts($ids) as $id => $context) {
+          $long_id = "@env:{$environment_name}:{$id}";
+          $this->contexts[$long_id] = $contexts[$long_id] = $context;
+        }
+      }
+    }
+
+    return $contexts;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getAvailableContexts() {
+    $contexts = [];
+    foreach ($this->getContextEnvironments() as $environment_name => $environment) {
+      foreach ($environment->getAvailableEnvironmentContexts() as $id => $context) {
+        $long_id = "@env:{$environment_name}:{$id}";
+        $contexts[$long_id] = $context;
+      }
+    }
+    $contexts += \Drupal::service('context.repository')->getAvailableContexts();
+    return $contexts;
+  }
+
+}
diff --git a/src/ProvidedContextEnvironmentTrait.php b/src/ProvidedContextEnvironmentTrait.php
new file mode 100644
index 0000000..099b591
--- /dev/null
+++ b/src/ProvidedContextEnvironmentTrait.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Drupal\ctools;
+
+use Drupal\Component\Plugin\Context\ContextInterface;
+
+trait ProvidedContextEnvironmentTrait {
+
+  /**
+   * Provided Contexts
+   *
+   * @var \Drupal\Core\Plugin\Context\ContextInterface[]
+   */
+  protected $provided_contexts = [];
+
+  /**
+   * Set a context at a given name.
+   *
+   * @param string $name
+   *   The name of the context in configuration.
+   * @param \Drupal\Component\Plugin\Context\ContextInterface $context
+   *   The context option to set.
+   */
+  public function setContext($name, ContextInterface $context) {
+    $this->provided_contexts[$name] = $context;
+  }
+
+  /**
+   * Build provided context values.
+   *
+   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
+   *   The provided contexts.
+   */
+  public function getProvidedContextValues() {
+    return $this->provided_contexts;
+  }
+
+  /**
+   * Get the available provided contexts.
+   *
+   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
+   *   The porovided contexts without values in.
+   */
+  abstract public function getAvailableProvidedContexts();
+
+}
+
